|
10 | 10 | // +----------------------------------------------------------------------
|
11 | 11 |
|
12 | 12 | // 应用公共文件
|
13 |
| -/** |
14 |
| - * 数据签名认证 |
15 |
| - * @param array $data 被认证的数据 |
16 |
| - * @return string 签名 |
17 |
| - * @author 清月曦 <1604583867@qq.com> |
18 |
| - */ |
19 |
| -function data_auth_sign($data) { |
20 |
| - //数据类型检测 |
21 |
| - if(!is_array($data)){ |
22 |
| - $data = (array)$data; |
23 |
| - } |
24 |
| - ksort($data); //排序 |
25 |
| - $code = http_build_query($data); //url编码并生成query字符串 |
26 |
| - $sign = sha1($code); //生成签名 |
27 |
| - return $sign; |
28 |
| -} |
29 |
| -/** |
30 |
| - * 下载远程文件 |
31 |
| - * @param string $url 网址 |
32 |
| - * @param string $filename 保存文件名 |
33 |
| - * @param integer $timeout 过期时间 |
34 |
| - * return boolean|string |
35 |
| - */ |
36 |
| -function http_down($url, $filename, $timeout = 60) { |
37 |
| - $path = dirname($filename); |
38 |
| - if (!is_dir($path) && !mkdir($path, 0755, true)) { |
39 |
| - return false; |
40 |
| - } |
41 |
| - $fp = fopen($filename, 'w'); |
42 |
| - $ch = curl_init($url); |
43 |
| - curl_setopt($ch, CURLOPT_FILE, $fp); |
44 |
| - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
45 |
| - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
46 |
| - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
47 |
| - curl_exec($ch); |
48 |
| - curl_close($ch); |
49 |
| - fclose($fp); |
50 |
| - return $filename; |
51 |
| -} |
52 | 13 |
|
53 |
| -// 防超时的file_get_contents改造函数 |
54 |
| -function wp_file_get_contents($url) |
55 |
| -{ |
56 |
| - $context = stream_context_create(array( |
57 |
| - 'http' => array( |
58 |
| - 'timeout' => 30 |
59 |
| - ) |
60 |
| - )); // 超时时间,单位为秒 |
61 |
| - |
62 |
| - return file_get_contents($url, 0, $context); |
63 |
| -} |
64 |
| -/** |
65 |
| -*解压文件 |
66 |
| -*/ |
67 |
| -function unzip($filePath, $toPath,$filesize=0){ |
68 |
| - // $length = filesize($filePath); |
69 |
| - // if ($filesize == $length) { |
70 |
| - $zip = new ZipArchive; |
71 |
| - $res = $zip->open($filePath); |
72 |
| - |
73 |
| - if ($res === TRUE) { |
74 |
| - //解压缩到指定文件夹 |
75 |
| - $zip->extractTo($toPath); |
76 |
| - $zip->close(); |
77 |
| - //删除压缩包 |
78 |
| - unlink($filePath); |
79 |
| - if ( is_dir( $toPath . '__MACOSX' ) ) { |
80 |
| - delDirAndFile($toPath . '__MACOSX'); |
81 |
| - } |
82 |
| - return true; |
83 |
| - }else{ |
84 |
| - return false; |
85 |
| - } |
86 |
| - // }else{ |
87 |
| - // return false; |
88 |
| - // } |
89 |
| -} |
90 | 14 |
|
91 | 15 |
|
92 | 16 |
|
|
0 commit comments