-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
127 lines (121 loc) · 2.91 KB
/
Copy pathfunction.php
File metadata and controls
127 lines (121 loc) · 2.91 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
function dbdebug(){
global $debug;
global $db;
if($debug){
$db->debug();
}else{
$db->hide_errors();
}
}
function pre($array){
global $debug;
if($debug){
echo "<pre>";
print_r($array);
echo "</pre>";
echo "<p>\$count=".count($array)."</p>";
}else{
//
}
}
function fecho($var){
global $debug;
if($debug){
echo "<p>".$var."</p>";
}else{
//
}
}
//使用array_keys搜索指定的值再循环unset)
function delByValue($arr, $value){
$keys = array_keys($arr, $value);
if(!empty($keys)){
foreach ($keys as $key) {
unset($arr[$key]);
}
}else{
//
}
return $arr;
}
//http加密传输
function httpencrypt($mingwen){
global $http_encrypt;
global $encrypt_method;
if($http_encrypt){
$aeskey=$_SESSION["aes_key"];
$aesiv=$_SESSION["aes_iv"];
$time=$_SESSION["aesgentime"];
$endata = openssl_encrypt(base64_encode($mingwen), $encrypt_method, $aeskey,0,$aesiv);
$data=array(
"time"=>$time,
"data"=>$endata
);
}else{
$data = array(
"data"=>$mingwen
);
}
return $data;
}
function httpdecrypt($miwen){
global $http_encrypt;
global $encrypt_method;
if($http_encrypt){
$aeskey=$_SESSION["aes_key"];
$aesiv=$_SESSION["aes_iv"];
$data = base64_decode(trim(openssl_decrypt($miwen,$encrypt_method,$aeskey,OPENSSL_ZERO_PADDING,$aesiv)));
}else{
$data = $miwen;
}
return $data;
}
/**
* @param string $code 状态码
* @param string $msg 返回信息
* @param string $data 返回数据
* @param array $other_results 为除 $code、$msg、$data 外,其他需要加入$result中的【不可加密的】数据,
* 如layui数据表格需要的count(总条数)等其他数据,
*
* $result=array(
* "code"=>0,
* "msg"=>"成功!",
* "data"=>$userlist, //加密数据
* "other"=>array( //不加密数据
* "count"=>$totalRows, //如 action/group.php,action/member.php
* "key1"=>"value1",
* "key2"=>"value2"
* )
* );
*
*
*/
function returnresult($code,$msg,$data,$other_results){
global $http_encrypt;
if($http_encrypt){
$data=httpencrypt(json_encode($data));
$result=array(
"code"=>$code,
"msg"=>$msg,
"time"=>$data["time"],
"data"=>$data["data"]
);
}else{
$result=array(
"code"=>$code,
"msg"=>$msg,
"data"=>$data
);
}
if(count($other_results)>0){
foreach($other_results as $key=>$value){
$result[$key]=$value;
}
}else{
//
}
header('Content-type: application/json');
echo json_encode($result);
}
?>