Upyun.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\index\controller;
  3. use app\common\controller\Frontend;
  4. use think\Config;
  5. /**
  6. * 又拍云异步接口
  7. */
  8. class Upyun extends Frontend
  9. {
  10. public function notify()
  11. {
  12. $url = $this->request->post("url");
  13. $code = $this->request->post("code");
  14. $message = $this->request->post("message");
  15. $sign = $this->request->post("sign");
  16. $time = $this->request->post("time");
  17. $extparam = $this->request->post("ext-param");
  18. if ($url && $code && $message && $time && $sign)
  19. {
  20. $arr = [$code, $message, $url, $time, Config::get('upload.formkey')];
  21. if ($extparam)
  22. {
  23. $arr[] = $extparam;
  24. }
  25. if ($sign == md5(implode('&', $arr)))
  26. {
  27. $params = array(
  28. 'filesize' => $this->request->param("file_size"),
  29. 'imagewidth' => $this->request->param("image-width"),
  30. 'imageheight' => $this->request->param("image-height"),
  31. 'imagetype' => $this->request->param("image-type"),
  32. 'imageframes' => $this->request->param("image-frames"),
  33. 'mimetype' => $this->request->param("mimetype"),
  34. 'extparam' => $extparam,
  35. 'url' => $url,
  36. 'uploadtime' => $time,
  37. 'storage' => 'upyun'
  38. );
  39. model("attachment")->create(array_filter($params));
  40. echo "success";
  41. }
  42. else
  43. {
  44. echo "failure";
  45. }
  46. }
  47. else
  48. {
  49. echo "failure";
  50. }
  51. return;
  52. }
  53. }