functions.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Here is your custom functions.
  4. */
  5. if (!function_exists('http_post')) {
  6. function http_post($url,$params){
  7. $ch = curl_init();
  8. $this_header = array("content-type: application/x-www-form-urlencoded;charset=UTF-8");
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
  10. curl_setopt($ch, CURLOPT_URL, $url);
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  12. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
  13. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  14. curl_setopt($ch, CURLOPT_POST, 1);
  15. curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  16. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);//如果不加验证,就设false,商户自行处理
  17. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  18. $output = curl_exec($ch);
  19. curl_close($ch);
  20. return $output;
  21. }
  22. }
  23. if (!function_exists('month_12')){
  24. function month_12(){
  25. $months = [];
  26. for ($i=0;$i<12;$i++){
  27. $months[$i] = date('Y/m',strtotime("-".$i."month"));
  28. }
  29. return $months;
  30. }
  31. }
  32. /**
  33. * @Desc 管理员操作日志
  34. * @Author Gorden
  35. * @Date 2024/3/29 17:07
  36. *
  37. * adminId = 1001 充值
  38. *
  39. *
  40. * @param $name
  41. * @param $operation
  42. * @return void
  43. */
  44. if (!function_exists('_syslog')) {
  45. function _syslog($name, $operation, $operationData = false, $requestParams = false, $adminId = false)
  46. {
  47. $logAdminId = $adminId ? $adminId : \Tinywan\Jwt\JwtToken::getCurrentId();
  48. $model = new \app\model\SysLog();
  49. $model->log_admin_id = $logAdminId;
  50. $model->log_name = $name;
  51. $model->log_route = \request()->uri() ?? \request()->route->getPath();
  52. $model->log_operation = $operation;
  53. $model->log_ip = \request()->getRealIp();
  54. $model->log_request_params = $requestParams ? json_encode($requestParams) : json_encode(\request()->all());
  55. $model->log_operation_data = $operationData ? json_encode($operationData) : null;
  56. $model->save();
  57. }
  58. }