public static function unserializeFromFile($filename, $secret = null) { if (!file_exists($filename)) { throw new TOException(_er("E_FILE_NOT_EXISTS", $filename)); } return unserialize(self::decrypt(file_get_contents($filename), $secret)); }
public function gets() { if (!$this->isNeedRead()) { display('reflash too fast~', 0); return; } $this->m_info['last_time'] = time(); $this->initOauth(); $parameter = $this->getParameters(); $json = $this->m_connection->get('statuses/user_timeline', $parameter); if (isset($json[0]['id_str'])) { $this->m_info['sinceId'] = $json[0]['id_str']; } $this->serializeInfo(); if (empty($json) || !is_array($json)) { display(_er('E_NO_UPDATE'), 0); } $result = array(); foreach ($json as $tweet) { $this->expandUrl($tweet); //array_push ( $result, $tweet ['text'] ); $result["{tweet_{$tweet['id_str']}}"] = trim($tweet['text']); } unset($json); $this->filter($result); return $result; }
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); }
<?php /** * ********************************************************* * * @author cluries * @link http://cdbit.com * @version 1.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) {
/** * ********************************************************* * * @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 exceptionHandler(Exception $ex) { try { L($ex->getMessage() . "\n" . $ex->getTraceAsString() . "\n\n"); $tpl = getTemplateInstance(); $tpl->title = _er('E_EXCEPTION_NOT_CATCH'); $tpl->debug = defined('APPLICATION_ENV') && (APPLICATION_ENV == 'development' || APPLICATION_ENV == 'testing'); $tpl->exception = $ex; $tpl->error = $ex->getMessage(); $tpl->display('exception'); } catch (Exception $e) { echo $e->getMessage(); } exit; }
<?php /** * ********************************************************* * * @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); session_start(); include BASE_PATH . '/config/config.inc.php'; include BASE_PATH . '/modules/init/bootstarp.php'; //display('Error Processing Request',0); //trigger_error("error_msg"); //throw new Exception("Error Processing Request", 1); $action = getVar('action', 'default'); $actionFile = "/modules/install/{$action}Action.php"; $actionVerify = '/^[a-zA-Z0-9]+$/'; preg_match($actionVerify, $action) && ttimport($actionFile) || display(_er('E_404'), 0);
<?php /** * ********************************************************* * * @author cluries * @link http://cdbit.com * @version 1.0 * @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');
<?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); }