Upyun.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. );
  38. model("attachment")->create(array_filter($params));
  39. echo "success";
  40. }
  41. else
  42. {
  43. echo "failure";
  44. }
  45. }
  46. else
  47. {
  48. echo "failure";
  49. }
  50. return;
  51. }
  52. }