config.php
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
defined('IN_IA') or exit('Access Denied');
class Config {
/**
* 证书的路径
* @param $uniacid
* @return array
*/
public static function getCertPaths($uniacid)
{
$salt = 'aa';
$partFileName = $uniacid.'_'.md5($uniacid.$salt);
$certFile = IA_ROOT . "/addons/zh_cjdianc/cert/" . 'apiclient_cert_' . $partFileName . '.pem';
$keyFile = IA_ROOT . "/addons/zh_cjdianc/cert/" . 'apiclient_key_' . $partFileName . '.pem';
return [$certFile, $keyFile];
}
/**
* @param $uniacid
* @return array
*/
public static function getServiceCertPaths($uniacid)
{
$salt = 'aa';
$partFileName = $uniacid.'_'.md5($uniacid.$salt);
$certFile = IA_ROOT . "/addons/zh_cjdianc/cert/" . 'apiclient_cert_service' . $partFileName . '.pem';
$keyFile = IA_ROOT . "/addons/zh_cjdianc/cert/" . 'apiclient_key_service' . $partFileName . '.pem';
return [$certFile, $keyFile];
}
/**
* @return string
*/
public static function getSignKey()
{
return "thisisasignkey100860";
}
/**
* @param $data
* @return string
*/
public static function genSign($data)
{
//1.升序排序
ksort($data);
//2.字符串拼接
$args = "";
foreach ($data as $key => $value) {
if ($key != 'sign') {
$args .= $key."=".$value."&";
}
}
$args = rtrim($args, "&");
$args = $args."&key=".self::getSignKey();
//3.MD5签名,转为大写
$sign = strtoupper(md5($args));
return $sign;
}
/**
* @param $data
* @return bool
*/
public static function checkSign($data)
{
if (empty($data) || !isset($data['sign'])) {
return false;
}
$postSign = $data['sign'];
if ($postSign == self::genSign($data)) {
return true;
} else {
return false;
}
}
static function IsDevProd()
{
return true;
}
}