控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Weburlpush.php 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 聚合推送管理
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\controller;
  15. use addons\weburlpush\library\Push;
  16. use app\common\controller\Adminbase;
  17. class Weburlpush extends Adminbase
  18. {
  19. public function index()
  20. {
  21. $config = get_addon_config('weburlpush');
  22. $config['status'] = explode(',', $config['status']);
  23. $this->assign('Config', $config);
  24. return $this->fetch();
  25. }
  26. //百度推送
  27. public function baidu(Push $push)
  28. {
  29. $action = $this->request->post("action");
  30. $urls = $this->request->post("urls");
  31. $urls = explode("\n", $urls);
  32. $urls = array_unique(array_filter($urls));
  33. if (!$urls) {
  34. $this->error("URL列表不能为空");
  35. }
  36. try {
  37. if ($action == 'push') {
  38. $result = $push->channel('baidu')->push($urls);
  39. } elseif ($action == 'del') {
  40. $result = $push->channel('baidu')->del($urls);
  41. }
  42. } catch (\Exception $e) {
  43. $this->error("百度推送失败:" . $e->getMessage());
  44. }
  45. $this->success("百度推送成功", '', $result);
  46. }
  47. //神马推送
  48. public function shenma(Push $push)
  49. {
  50. $action = $this->request->post("action");
  51. $urls = $this->request->post("urls");
  52. $urls = explode("\n", $urls);
  53. $urls = array_unique(array_filter($urls));
  54. if (!$urls) {
  55. $this->error("URL列表不能为空");
  56. }
  57. try {
  58. if ($action == 'push') {
  59. $result = $push->channel('shenma')->push($urls);
  60. } elseif ($action == 'del') {
  61. $result = $push->channel('shenma')->del($urls);
  62. }
  63. } catch (\Exception $e) {
  64. $this->error("神马推送失败:" . $e->getMessage());
  65. }
  66. $this->success("神马推送成功", '', $result);
  67. }
  68. }