Açıklama Yok

helpers.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. if (!function_exists('getTimeRangeArr')) {
  3. /**
  4. * 获取时间段数组
  5. * @param $stTime
  6. * @param $enTime
  7. * @param int $step
  8. * @return array
  9. */
  10. function getTimeRangeArr($stTime, $enTime, $step = 14)
  11. {
  12. $timeRangeArr = [];
  13. while ($stTime < $enTime) {
  14. $stTimeStr = strtotime($stTime);
  15. $clTime = date('Y-m-d', $stTimeStr + (86400 * $step));
  16. if ($clTime >= $enTime) {
  17. $clTime = $enTime;
  18. }
  19. $temp = [
  20. 'st' => $stTime,
  21. 'en' => $clTime
  22. ];
  23. $timeRangeArr[] = $temp;
  24. $stTime = date('Y-m-d', $stTimeStr + (86400 * ($step + 1)));
  25. }
  26. return $timeRangeArr;
  27. }
  28. }
  29. if (!function_exists('getDayArr')) {
  30. /**
  31. * 获取时间数组
  32. * @param $stTime
  33. * @param $enTime
  34. * @param int $step
  35. * @return array
  36. */
  37. function getDayArr($stTime, $enTime, $formatData)
  38. {
  39. $dayArr = [];
  40. while ($stTime <= $enTime) {
  41. $temp = $formatData;
  42. $temp['day'] = $stTime;
  43. $dayArr[] = $temp;
  44. $stTime = date('Y-m-d', strtotime($stTime) + 86400);
  45. unset($temp);
  46. }
  47. return $dayArr;
  48. }
  49. }
  50. function h5_set_sign($params)
  51. {
  52. if(empty($params)){
  53. return false;
  54. }
  55. $str = '';
  56. ksort($params);
  57. foreach($params as $k=>$v){
  58. if(is_array($v)){
  59. $v = json_encode($v);
  60. }
  61. $str .= $k.'='.$v;
  62. }
  63. $solt = 'ur904wtr5pfctaw5';
  64. $sign = md5(md5($str) . $solt);
  65. return $sign;
  66. }
  67. function h5_verify_sign($params)
  68. {
  69. if( empty($params) || !isset($params['sign']) ){
  70. return false;
  71. }
  72. $sign = $params['sign'];
  73. unset($params['sign']);
  74. $_sign = h5_set_sign($params);
  75. if($sign == $_sign){
  76. return true;
  77. }
  78. return false;
  79. }