-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f8c6832
Showing
4,854 changed files
with
560,514 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ShopNC 西恩纽约版 | ||
本版本是基于运维舫(shopnc.club)定制的 | ||
|
||
## 使用步骤 | ||
1. 安装 | ||
通过 MySQL 搭建相应的数据库,访问源码位置,会自动进入安装步骤,根据提示操作 | ||
|
||
2. 清空缓存 | ||
安装完毕后必须清空缓存,新部署才会生效 | ||
|
||
## 版本关系 | ||
ShopNC -> 好商城 201511 版本 -> 运维舫定制 -> 西恩纽约版 | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
<?php | ||
/** | ||
* 支付宝退款有密接口 | ||
* | ||
* 二十四小时在线技术Q:76809326 | ||
* | ||
* by 运维舫 www.shopnc.club 运营版 | ||
*/ | ||
defined('InShopNC') or exit('Access Invalid!'); | ||
|
||
require_once("alipay.function.php"); | ||
|
||
class AlipayNotify { | ||
/** | ||
* HTTPS形式消息验证地址 | ||
*/ | ||
var $https_verify_url = 'https://mapi.alipay.com/gateway.do?service=notify_verify&'; | ||
/** | ||
* HTTP形式消息验证地址 | ||
*/ | ||
var $http_verify_url = 'http://notify.alipay.com/trade/notify_query.do?'; | ||
var $alipay_config; | ||
|
||
function __construct($alipay_config){ | ||
$alipay_config['sign_type'] = strtoupper('MD5'); | ||
$this->alipay_config = $alipay_config; | ||
} | ||
function AlipayNotify($alipay_config) { | ||
$this->__construct($alipay_config); | ||
} | ||
/** | ||
* 针对notify_url验证消息是否是支付宝发出的合法消息 | ||
* @return 验证结果 | ||
*/ | ||
function verifyNotify(){ | ||
if(empty($_POST)) {//判断POST来的数组是否为空 | ||
return false; | ||
} | ||
else { | ||
//生成签名结果 | ||
$isSign = $this->getSignVeryfy($_POST, $_POST["sign"]); | ||
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息) | ||
$responseTxt = 'true'; | ||
if (! empty($_POST["notify_id"])) {$responseTxt = $this->getResponse($_POST["notify_id"]);} | ||
if (preg_match("/true$/i",$responseTxt) && $isSign) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* 获取返回时的签名验证结果 | ||
* @param $para_temp 通知返回来的参数数组 | ||
* @param $sign 返回的签名结果 | ||
* @return 签名验证结果 | ||
*/ | ||
function getSignVeryfy($para_temp, $sign) { | ||
//除去待签名参数数组中的空值和签名参数 | ||
$para_filter = paraFilter($para_temp); | ||
|
||
//对待签名参数数组排序 | ||
$para_sort = argSort($para_filter); | ||
|
||
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 | ||
$prestr = createLinkstring($para_sort); | ||
|
||
$isSgin = false; | ||
switch (strtoupper(trim($this->alipay_config['sign_type']))) { | ||
case "MD5" : | ||
$isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']); | ||
break; | ||
default : | ||
$isSgin = false; | ||
} | ||
|
||
return $isSgin; | ||
} | ||
|
||
/** | ||
* 获取远程服务器ATN结果,验证返回URL | ||
* @param $notify_id 通知校验ID | ||
* @return 服务器ATN结果 | ||
* 验证结果集: | ||
* invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空 | ||
* true 返回正确信息 | ||
* false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟 | ||
*/ | ||
function getResponse($notify_id) { | ||
$partner = trim($this->alipay_config['partner']); | ||
$veryfy_url = ''; | ||
if(extension_loaded('openssl')) { | ||
$veryfy_url = $this->https_verify_url; | ||
} | ||
else { | ||
$veryfy_url = $this->http_verify_url; | ||
} | ||
$veryfy_url = $veryfy_url."partner=" . $partner . "¬ify_id=" . $notify_id; | ||
$responseTxt = getHttpResponseGET($veryfy_url, getcwd().'/cacert.pem'); | ||
return $responseTxt; | ||
} | ||
} | ||
class AlipaySubmit { | ||
|
||
var $alipay_config; | ||
/** | ||
*支付宝网关地址(新) | ||
*/ | ||
var $alipay_gateway_new = 'https://mapi.alipay.com/gateway.do?'; | ||
|
||
function __construct($alipay_config){ | ||
$alipay_config['sign_type'] = strtoupper('MD5'); | ||
$this->alipay_config = $alipay_config; | ||
} | ||
function AlipaySubmit($alipay_config) { | ||
$this->__construct($alipay_config); | ||
} | ||
|
||
/** | ||
* 生成签名结果 | ||
* @param $para_sort 已排序要签名的数组 | ||
* return 签名结果字符串 | ||
*/ | ||
function buildRequestMysign($para_sort) { | ||
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 | ||
$prestr = createLinkstring($para_sort); | ||
|
||
$mysign = ""; | ||
switch (strtoupper(trim($this->alipay_config['sign_type']))) { | ||
case "MD5" : | ||
$mysign = md5Sign($prestr, $this->alipay_config['key']); | ||
break; | ||
default : | ||
$mysign = ""; | ||
} | ||
|
||
return $mysign; | ||
} | ||
|
||
/** | ||
* 生成要请求给支付宝的参数数组 | ||
* @param $para_temp 请求前的参数数组 | ||
* @return 要请求的参数数组 | ||
*/ | ||
function buildRequestPara($para_temp) { | ||
//除去待签名参数数组中的空值和签名参数 | ||
$para_filter = paraFilter($para_temp); | ||
|
||
//对待签名参数数组排序 | ||
$para_sort = argSort($para_filter); | ||
|
||
//生成签名结果 | ||
$mysign = $this->buildRequestMysign($para_sort); | ||
|
||
//签名结果与签名方式加入请求提交参数组中 | ||
$para_sort['sign'] = $mysign; | ||
$para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type'])); | ||
|
||
return $para_sort; | ||
} | ||
|
||
/** | ||
* 生成要请求给支付宝的参数数组 | ||
* @param $para_temp 请求前的参数数组 | ||
* @return 要请求的参数数组字符串 | ||
*/ | ||
function buildRequestParaToString($para_temp) { | ||
//待请求参数数组 | ||
$para = $this->buildRequestPara($para_temp); | ||
|
||
//把参数组中所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码 | ||
$request_data = $this->alipay_gateway_new.createLinkstringUrlencode($para); | ||
|
||
return $request_data; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?php | ||
/** | ||
* 支付宝接口公用函数 | ||
* | ||
* 二十四小时在线技术Q:76809326 | ||
* | ||
* by 运维舫 www.shopnc.club 运营版 | ||
*/ | ||
|
||
defined('InShopNC') or exit('Access Invalid!'); | ||
/** | ||
* 参数数组 | ||
*/ | ||
function getPara($alipay_config) { | ||
$parameter = array( | ||
"service" => "refund_fastpay_by_platform_pwd", | ||
"partner" => trim($alipay_config['partner']), | ||
"notify_url" => ADMIN_SITE_URL."/api/refund/alipay/notify_url.php", | ||
"seller_email" => trim($alipay_config['seller_email']), | ||
"refund_date" => date('Y-m-d H:i:s'), | ||
"batch_no" => '', | ||
"batch_num" => '1', | ||
"detail_data" => '', | ||
"_input_charset" => strtolower('utf-8') | ||
); | ||
return $parameter; | ||
} | ||
/** | ||
* 签名字符串 | ||
* @param $prestr 需要签名的字符串 | ||
* @param $key 私钥 | ||
* return 签名结果 | ||
*/ | ||
function md5Sign($prestr, $key) { | ||
$prestr = $prestr . $key; | ||
return md5($prestr); | ||
} | ||
|
||
/** | ||
* 验证签名 | ||
* @param $prestr 需要签名的字符串 | ||
* @param $sign 签名结果 | ||
* @param $key 私钥 | ||
* return 签名结果 | ||
*/ | ||
function md5Verify($prestr, $sign, $key) { | ||
$prestr = $prestr . $key; | ||
$mysgin = md5($prestr); | ||
|
||
if($mysgin == $sign) { | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
/** | ||
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 | ||
* @param $para 需要拼接的数组 | ||
* return 拼接完成以后的字符串 | ||
*/ | ||
function createLinkstring($para) { | ||
$arg = ""; | ||
while (list ($key, $val) = each ($para)) { | ||
$arg.=$key."=".$val."&"; | ||
} | ||
//去掉最后一个&字符 | ||
$arg = substr($arg,0,count($arg)-2); | ||
|
||
//如果存在转义字符,那么去掉转义 | ||
if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} | ||
|
||
return $arg; | ||
} | ||
/** | ||
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码 | ||
* @param $para 需要拼接的数组 | ||
* return 拼接完成以后的字符串 | ||
*/ | ||
function createLinkstringUrlencode($para) { | ||
$arg = ""; | ||
while (list ($key, $val) = each ($para)) { | ||
$arg.=$key."=".urlencode($val)."&"; | ||
} | ||
//去掉最后一个&字符 | ||
$arg = substr($arg,0,count($arg)-2); | ||
|
||
//如果存在转义字符,那么去掉转义 | ||
if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} | ||
|
||
return $arg; | ||
} | ||
/** | ||
* 除去数组中的空值和签名参数 | ||
* @param $para 签名参数组 | ||
* return 去掉空值与签名参数后的新签名参数组 | ||
*/ | ||
function paraFilter($para) { | ||
$para_filter = array(); | ||
while (list ($key, $val) = each ($para)) { | ||
if($key == "sign" || $key == "sign_type" || $val == "")continue; | ||
else $para_filter[$key] = $para[$key]; | ||
} | ||
return $para_filter; | ||
} | ||
/** | ||
* 对数组排序 | ||
* @param $para 排序前的数组 | ||
* return 排序后的数组 | ||
*/ | ||
function argSort($para) { | ||
ksort($para); | ||
reset($para); | ||
return $para; | ||
} | ||
|
||
/** | ||
* 远程获取数据,GET模式 | ||
* 注意: | ||
* 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了 | ||
* 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem' | ||
* @param $url 指定URL完整路径地址 | ||
* @param $cacert_url 指定当前工作目录绝对路径 | ||
* return 远程输出的数据 | ||
*/ | ||
function getHttpResponseGET($url,$cacert_url) { | ||
$curl = curl_init($url); | ||
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头 | ||
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果 | ||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);//SSL证书认证 | ||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);//严格认证 | ||
curl_setopt($curl, CURLOPT_CAINFO,$cacert_url);//证书地址 | ||
$responseText = curl_exec($curl); | ||
//var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容 | ||
curl_close($curl); | ||
|
||
return $responseText; | ||
} | ||
?> |
Oops, something went wrong.