Пример #1
0
 private function reflashToken()
 {
     if (empty($this->m_cfg['username']) || empty($this->m_cfg['password'])) {
         return;
     }
     $this->m_reflash_cookie = tmpDir('reflashsina.cookie');
     if (!file_exists($this->m_reflash_cookie)) {
         touch($this->m_reflash_cookie);
     }
     $loginResult = $this->curlLoginSina($this->m_cfg['username'], $this->m_cfg['password']);
     if (!$loginResult) {
         return $loginResult;
     }
     $callbackUrl = callbackUrl('sina');
     $o = new SaeTOAuthV2($this->m_cfg['key'], $this->m_cfg['secret']);
     $authorizeURL = $o->getAuthorizeURL($callbackUrl);
     $ch = curl_init($authorizeURL);
     $option = array();
     $option[CURLOPT_FOLLOWLOCATION] = 1;
     $option[CURLOPT_RETURNTRANSFER] = 1;
     $option[CURLOPT_COOKIEJAR] = $this->m_reflash_cookie;
     $option[CURLOPT_COOKIEFILE] = $this->m_reflash_cookie;
     $option[CURLOPT_HTTPHEADER] = array('Accept-Language: zh-cn', 'Connection: Keep-Alive', 'Cache-Control: no-cache');
     $option[CURLOPT_USERAGENT] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
     curl_setopt_array($ch, $option);
     curl_exec($ch);
     curl_close($ch);
     unlink($this->m_reflash_cookie);
 }
Пример #2
0
 public function post($tweet)
 {
     $response = httpRequest(self::POST_URL, $this->generatePostParams($tweet));
     $token = $this->m_oauth->getRefreshToken($this->m_token['refresh_token']);
     if (!empty($token['access_token']) && !empty($token['refresh_token'])) {
         Encryption::serializeToFile($token, tmpDir('renren.oauth'));
     }
 }
Пример #3
0
 public function testErrorDie()
 {
     exec('/usr/bin/env php ' . __DIR__ . DIRECTORY_SEPARATOR . 'errordie.php', $out);
     $message = join(PHP_EOL, $out);
     $message = str_replace(tmpDir(), '<cachedir>/', $message);
     // Remove system specific cache dir
     $expected = join(PHP_EOL, array('==> First call (cache should be missed)', 'Cache Missed !', '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277'));
     $this->assertEquals($message, $expected);
 }
Пример #4
0
 private function __construct()
 {
     $this->m_target_file = tmpDir('targets.targets');
     if (!file_exists($this->m_target_file)) {
         $this->m_target_set = array();
         return;
     }
     $this->m_target_set = Encryption::unserializeFromFile($this->m_target_file);
 }
Пример #5
0
 public function __construct($cfg)
 {
     $this->m_cfg = $cfg;
     $this->m_filters = array(array($this, 'ftForceSync'), array($this, 'ftForceNSync'), array($this, 'ftLevel'));
     $this->m_after_filters = array();
     $this->m_info_file = tmpDir($this->m_source_type . '.info');
     $this->m_token_file = tmpDir($this->m_source_type . '.oauth');
     if (!file_exists($this->m_token_file)) {
         throw new TOException(_er('E_SOURCE_FILE_NOT_EXISTS', $this->m_info_file, $this->m_token_file));
         return;
     }
     if (file_exists($this->m_info_file)) {
         //$this->m_info  = Encryption::unserializeFromFile  ( $this->m_info_file );
         $this->m_info = unserialize(file_get_contents($this->m_info_file));
     }
     $this->m_token = Encryption::unserializeFromFile($this->m_token_file);
 }
Пример #6
0
 * @copyright 2012 http://cdbit.com All rights reserved
 * 
 * *********************************************************
 */
if (islocked('sina')) {
    $takedToken = Encryption::unserializeFromFile(tmpDir('sina.oauth'));
    if (!($takedToken['auth_timestamp'] + $takedToken['expires_in'] < time() - 10)) {
        display(_er('E_LOCKED', 'sina', 'sina'), 0);
    }
}
import('/library/saetv2.ex.class.php');
global $cfg_sina;
$o = new SaeTOAuthV2($cfg_sina['key'], $cfg_sina['secret']);
if (!isset($_REQUEST['code'])) {
    display('sina认证失败');
}
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = callbackUrl('sina');
$token = false;
try {
    $token = $o->getAccessToken('code', $keys);
} catch (OAuthException $e) {
    display('sina认证失败:' . $e->getMessage());
}
if ($token) {
    $token['auth_timestamp'] = time();
    Encryption::serializeToFile($token, tmpDir('sina.oauth'));
    lockit('sina');
    display('sina认证成功');
}
 * @author cluries
 * @link http://cdbit.com
 * @version 1.0
 * @copyright 2012 http://cdbit.com All rights reserved
 * 
 * *********************************************************
 */
if (islocked('douban')) {
    display(_er('E_LOCKED', 'douban', 'douban'), 0);
}
if (empty($_REQUEST['oauth_token'])) {
    display(_er('E_404'), 0);
}
if ($_SESSION['douban_token'] != $_REQUEST['oauth_token']) {
    retry();
}
import('/library/OAuth.php');
import('/library/doubanoauth.php');
global $cfg_douban;
$o = new DoubanOAuth($cfg_douban['key'], $cfg_douban['secret'], $_SESSION['douban_token'], $_SESSION['douban_token_secret']);
$token = $o->getAccessToken();
if (!empty($token['oauth_token_secret']) && !empty($token['oauth_token'])) {
    Encryption::serializeToFile($token, tmpDir('douban.oauth'));
    lockit('douban');
    display('douban认证成功');
}
display('douban认证失败');
function retry()
{
    Header("Location:install.php?action=auth");
}
Пример #8
0
function lockit($type)
{
    file_put_contents(tmpDir("locks/{$type}.lock"), time());
}
Пример #9
0
 public function initOAuth()
 {
     $this->m_token = Encryption::unserializeFromFile(tmpDir('tencent.oauth'));
     $this->m_oauth = new MBOpenTOAuth($this->m_cfg['key'], $this->m_cfg['secret'], $this->m_token['oauth_token'], $this->m_token['oauth_token_secret']);
 }
<?php

/**
 * Executed by ErrorDieTest
 *
 * @package Cache_Lite
 * @category Caching
 * @version $Id$
 * @author Markus Tacker <*****@*****.**>
 */
require_once 'callcache.inc';
require_once 'tmpdir.inc';
require_once 'cache_lite_base.inc';
error_reporting(0);
$options = array('cacheDir' => tmpDir() . '31451992gjhgjh' . '/', 'lifeTime' => 60, 'pearErrorMode' => CACHE_LITE_ERROR_DIE);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();
 * @copyright 2012 http://cdbit.com All rights reserved
 * 
 * *********************************************************
 */
import('/library/OAuth.php');
import('/library/twitteroauth.php');
if (islocked('twitter')) {
    display(_er('E_LOCKED', 'twitter', 'twitter'), 0);
}
if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] != $_REQUEST['oauth_token']) {
    retry();
}
global $cfg_source;
$connection = new TwitterOAuth($cfg_source['key'], $cfg_source['secret'], $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
$access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
$_SESSION['access_token'] = $access_token;
unset($_SESSION['oauth_token']);
unset($_SESSION['oauth_token_secret']);
if (200 == $connection->http_code) {
    $_SESSION['status'] = 'verified';
    //updateOauth ( $access_token );
    Encryption::serializeToFile($access_token, tmpDir('twitter.oauth'));
    lockit('twitter');
    display('Twiter认证成功');
} else {
    retry();
}
function retry()
{
    Header("Location:install.php?action=auth");
}
Пример #12
0
/**
 * *********************************************************
 * 
 * @author cluries
 * @link http://cdbit.com
 * @version 1.0
 * @copyright 2012 http://cdbit.com All rights reserved
 * 
 * *********************************************************
 */
if (islocked('renren')) {
    display(_er('E_LOCKED', 'renren', 'renren'), 0);
}
if (empty($_REQUEST['code'])) {
    display(_er('E_404'), 0);
}
global $cfg_renren;
import('/library/renrenoauth.php');
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = callbackUrl('renren');
try {
    $o = new RenrenOAuth($cfg_renren['key'], $cfg_renren['secret']);
    $token = $o->getAccessToken($_REQUEST['code'], callbackUrl('renren'));
    Encryption::serializeToFile($token, tmpDir('renren.oauth'));
    lockit('renren');
    display('renren认证成功');
} catch (OAuthException $e) {
    display('renren认证失败', 0);
}
Пример #13
0
 * *********************************************************
 * 
 * @author cluries
 * @link http://cdbit.com
 * @version 1.0
 * @copyright 2012 http://cdbit.com All rights reserved
 * 
 * *********************************************************
 */
define('START_TIME', microtime(true));
define('BASE_PATH', dirname(__FILE__));
define('DEBUG', true);
include BASE_PATH . '/config/config.inc.php';
include BASE_PATH . '/modules/init/bootstarp.php';
$twitter = new Twitter_Source($cfg_twitter);
$tweets = $twitter->gets();
if (empty($tweets)) {
    display("Tw2other run well but there is no tweets need to sync");
}
$modules = array('Sina', 'Tencent', 'Renren', 'Douban', 'Fanfou');
foreach ($modules as $m) {
    if (!file_exists(tmpDir(strtolower($m) . '.oauth'))) {
        continue;
    }
    $target = "{$m}_Sync";
    $config = 'cfg_' . strtolower($m);
    $target = new $target(${$config});
    $target->sets($tweets);
    $target->sync();
}
display('^_^');
<?php

/**
 * *********************************************************
 * 
 * @author cluries
 * @link http://cdbit.com
 * @version 1.0
 * @copyright 2012 http://cdbit.com All rights reserved
 * 
 * *********************************************************
 */
if (islocked('tencent')) {
    display(_er('E_LOCKED', 'tencent', 'tencent'), 0);
}
empty($_SESSION['tencent_keys']) && display('SESSION中没找到对应的KEY', 0);
import('/library/OAuth.php');
import('/library/tencentoauth.php');
global $cfg_tencent;
$o = new MBOpenTOAuth($cfg_tencent['key'], $cfg_tencent['secret'], $_SESSION['tencent_keys']['oauth_token'], $_SESSION['tencent_keys']['oauth_token_secret']);
unset($_SESSION['tencent_keys']);
$last_key = $o->getAccessToken($_REQUEST['oauth_verifier']);
if (!empty($last_key['oauth_token']) && !empty($last_key['oauth_token_secret'])) {
    Encryption::serializeToFile($last_key, tmpDir('tencent.oauth'));
    lockit('tencent');
    display('Tencent认证成功');
} else {
    display('Tencent认证失败', 0);
}