123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- if (!function_exists('getTimeRangeArr')) {
- /**
- * 获取时间段数组
- * @param $stTime
- * @param $enTime
- * @param int $step
- * @return array
- */
- function getTimeRangeArr($stTime, $enTime, $step = 14)
- {
- $timeRangeArr = [];
- while ($stTime < $enTime) {
- $stTimeStr = strtotime($stTime);
- $clTime = date('Y-m-d', $stTimeStr + (86400 * $step));
- if ($clTime >= $enTime) {
- $clTime = $enTime;
- }
- $temp = [
- 'st' => $stTime,
- 'en' => $clTime
- ];
- $timeRangeArr[] = $temp;
- $stTime = date('Y-m-d', $stTimeStr + (86400 * ($step + 1)));
- }
- return $timeRangeArr;
- }
- }
- if (!function_exists('getDayArr')) {
- /**
- * 获取时间数组
- * @param $stTime
- * @param $enTime
- * @param int $step
- * @return array
- */
- function getDayArr($stTime, $enTime, $formatData)
- {
- $dayArr = [];
- while ($stTime <= $enTime) {
- $temp = $formatData;
- $temp['day'] = $stTime;
- $dayArr[] = $temp;
- $stTime = date('Y-m-d', strtotime($stTime) + 86400);
- unset($temp);
- }
- return $dayArr;
- }
- }
- function h5_set_sign($params)
- {
- if(empty($params)){
- return false;
- }
- $str = '';
- ksort($params);
- foreach($params as $k=>$v){
- if(is_array($v)){
- $v = json_encode($v);
- }
- $str .= $k.'='.$v;
- }
- $solt = 'ur904wtr5pfctaw5';
- $sign = md5(md5($str) . $solt);
- return $sign;
- }
- function h5_verify_sign($params)
- {
- if( empty($params) || !isset($params['sign']) ){
- return false;
- }
- $sign = $params['sign'];
- unset($params['sign']);
-
- $_sign = h5_set_sign($params);
- if($sign == $_sign){
- return true;
- }
- return false;
- }
|