<?php
/*
* Code based on:
* Abraham Williams (abraham@abrah.am) http://abrah.am
*/
/* Load OAuth lib. You can find it at http://oauth.net */
/**
* @ignore
*/
class OAuthException extends Exception {
// pass
}
/**
* @ignore
*/
class OAuthConsumer {
public $key;
public $secret;
function __construct($key, $secret) {
$this->key = $key;
$this->secret = $secret;
}
function __toString() {
return "OAuthConsumer[key=$this->key,secret=$this->secret]";
}
}
/**
* @ignore
*/
class OAuthToken {
// access tokens and request tokens
public $key;
public $secret;
/**
* key = the token
* secret = the token secret
*/
function __construct($key, $secret) {
$this->key = $key;
$this->secret = $secret;
}
/**
* generates the basic string serialization of a token that a server
* would respond to request_token and access_token calls with
*/
function to_string() {
return "oauth_token=" .
OAuthUtil::urlencode_rfc3986($this->key) .
"&oauth_token_secret=" .
OAuthUtil::urlencode_rfc3986($this->secret);
}
function __toString() {
return $this->to_string();
}
}
/**
* @ignore
*/
class OAuthSignatureMethod {
public function check_signature(&$request, $consumer, $token, $signature) {
$built = $this->build_signature($request, $consumer, $token);
return $built == $signature;
}
}
/**
* @ignore
*/
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
function get_name() {
return "HMAC-SHA1";
}
public function build_signature($request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
//print_r( $base_string );
$request->base_string = $base_string;
$key_parts = array(
$consumer->secret,
($token) ? $token->secret : ""
);
//print_r( $key_parts );
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
return base64_encode(hash_hmac('sha1', $base_string, $key, true));
}
}
/**
* @ignore
*/
class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
public function get_name() {
return "PLAINTEXT";
}
public function build_signature($request, $consumer, $token) {
$sig = array(
OAuthUtil::urlencode_rfc3986($consumer->secret)
);
if ($token) {
array_push($sig, OAuthUtil::urlencode_rfc3986($token->secret));
} else {
array_push($sig, '');
}
$raw = implode("&", $sig);
// for debug purposes
$request->base_string = $raw;
return OAuthUtil::urlencode_rfc3986($raw);
}
}
/**
* @ignore
*/
class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
public function get_name() {
return "RSA-SHA1";
}
protected function fetch_public_cert(&$request) {
// not implemented yet, ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
// (2) fetch via http using a url provided by the requester
// (3) some sort of specific discovery code based on request
//
// either way should return a string representation of the certificate
throw Exception("fetch_public_cert not implemented");
}
protected function fetch_private_cert(&$request) {
// not implemented yet, ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
//
// either way should return a string representation of the certificate
throw Exception("fetch_private_cert not implemented");
}
public function build_signature(&$request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
$request->base_string = $base_string;
// Fetch the private key cert based on the request
$cert = $this->fetch_private_cert($request);
// Pull the private key ID from the certificate
$privatekeyid = openssl_get_privatekey($cert);
// Sign using the key
$ok = openssl_sign($base_string, $signature, $privatekeyid);
// Release the key resource
openssl_free_key($privatekeyid);
return base64_encode($signature);
}
public function check_signature(&$request, $consumer, $token, $signature) {
$decoded_sig = base64_decode($signature);
$base_string = $request->get_signature_base_string();
// Fetch the public key cert based on the request
$cert = $this->fetch_public_cert($request);
// Pull the public key ID from the certificate
$publickeyid = openssl_get_publickey($cert);
// Check the computed signature against the one passed in the query
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
// Release the key resource
openssl_free_key($publickeyid);
return $ok == 1;
}
}
/**
* @ignore
*/
class OAuthRequest {
private $parameters;
private $http_method;
private $http_url;
// for debug purposes
public $base_string;
public static $version = '1.0a';
public static $POST_INPUT = 'php://input';
function __construct($http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$this->parameters = $parameters;
$this->http_method = $http_method;
$this->http_url = $http_url;
}
/**
* attempt to build up a request from what was passed to the server
*/
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
? 'http'
: 'https';
@$http_url or $http_url = $scheme .
'://' . $_SERVER['HTTP_HOST'] .
':' .
$_SERVER['SERVER_PORT'] .
$_SERVER['REQUEST_URI'];
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
// We weren't handed any parameters, so let's find the ones relevant to
// this request.
// If you run XML-RPC or similar you should use this to provide your own
// parsed parameter-list
if (!$parameters) {
// Find request headers
$request_headers = OAuthUtil::get_headers();
// Parse the query-string to find GET parameters
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
// It's a POST request of the proper content-type, so parse POST
// parameters and add those overriding any duplicates from GET
if ($http_method == "POST"
&& @strstr($request_headers["Content-Type"],
"application/x-www-form-urlencoded")
) {
$post_data = OAuthUtil::parse_parameters(
file_get_contents(self::$POST_INPUT)
);
$parameters = array_merge($parameters, $post_data);
}
// We have a Authorization-header with OAuth data. Parse the header
// and add those overriding any duplicates from GET or POST
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
$header_parameters = OAuthUtil::split_header(
$request_headers['Authorization']
);
$parameters = array_merge($parameters, $header_parameters);
}
}
return new OAuthRequest($http_method, $http_url, $parameters);
}
/**
* pretty much a helper function to set up the request
*/
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共50个文件
php:24个
html:17个
gif:5个
ZuituGo_Patch_CV2.0_1768_1792 1、优化支付代码、更容易加入新的支付方式 2、增加易宝支付,提供网银直连可选设置 3、后台可删除用户点评 4、导航栏的修改,独立为模板文件 block_navigator.html,方便修改 5、增加团购预告功能 6、增加第三方微薄登录(新浪),后续考虑增加支付宝、腾讯等 7、修改商户下载券的小bug n、待完善 演示:优惠团,http://www.youhuit.com
资源推荐
资源详情
资源评论
收起资源包目录
ZuituGo_Patch_CV2.0_1768_1792.tar.gz (50个子文件)
biz
down.php 3KB
thirdpart
sina
update.php 153B
config.php 211B
login.php 297B
callback.php 307B
auth.php 1KB
weibooauth.php 52KB
static
css
index.css 66KB
i
shundexin.gif 3KB
huaxia.gif 3KB
banklist.png 25KB
guangzhoushangye.gif 3KB
guangnongxin.gif 4KB
shangnongshang.gif 4KB
theme
YellowUMZZ
css
index.css 65KB
include
db
db.sql 24KB
application.php 2KB
template
credit_charge.html 4KB
manage_system_pay.html 7KB
order_check.html 7KB
order_charge.html 1KB
manage_system_option.html 7KB
block_pay_yeepay.html 1KB
order_pay.html 1KB
header.html 3KB
block_pay_tenpay.html 376B
team_current.html 2KB
block_pay_paypal.html 2KB
block_pay_alipay.html 376B
block_pay_chinabank.html 650B
block_pay_bill.html 2KB
manage_misc_comment.html 2KB
block_navigator.html 652B
manage_market_downorder.html 2KB
function
utility.php 4KB
common.php 20KB
pay.php 18KB
current.php 10KB
api
baidu.php 2KB
credit
charge.php 583B
team
predict.php 675B
manage
misc
comment.php 1KB
team
down.php 2KB
market
downorder.php 2KB
order
yeepay
yeepayCommon.php 2KB
callback.php 2KB
check.php 2KB
pay.php 4KB
paybank.php 1KB
charge.php 964B
共 50 条
- 1
资源评论
普通网友
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功