Urlsend.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <?php
  2. namespace app\admin\controller;
  3. class Urlsend extends Base
  4. {
  5. public $_lastid='';
  6. public $_param;
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. $this->_param = input();
  11. }
  12. public function index()
  13. {
  14. if (Request()->isPost()) {
  15. $config = input();
  16. $config_new['urlsend'] = $config['urlsend'];
  17. $config_old = config('maccms');
  18. $config_new = array_merge($config_old, $config_new);
  19. $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
  20. if ($res === false) {
  21. return $this->error(lang('save_err'));
  22. }
  23. return $this->success(lang('save_ok'));
  24. }
  25. $urlsend_config = $GLOBALS['config']['urlsend'];
  26. $this->assign('config',$urlsend_config);
  27. $extends = mac_extends_list('urlsend');
  28. $this->assign('extends',$extends);
  29. $this->assign('title',lang('admin/urlsend/title'));
  30. return $this->fetch('admin@urlsend/index');
  31. }
  32. public function data()
  33. {
  34. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  35. $list = [];
  36. $mid = $this->_param['mid'];
  37. $this->_param['page'] = intval($this->_param['page']) <1 ? 1 : $this->_param['page'];
  38. $this->_param['limit'] = intval($this->_param['limit']) <1 ? 50 : $this->_param['limit'];
  39. $ids = $this->_param['ids'];
  40. $ac2 = $this->_param['ac2'];
  41. $col_time = 'time';
  42. if($this->_param['range'] == '1'){
  43. $col_time = 'time_add';
  44. }
  45. $today = strtotime(date('Y-m-d'));
  46. $where = [];
  47. $col = '';
  48. switch($mid)
  49. {
  50. case 1:
  51. $where['vod_status'] = ['eq',1];
  52. if($ac2=='today'){
  53. $where['vod_'.$col_time] = ['gt',$today];
  54. }
  55. if(!empty($ids)){
  56. $where['vod_id'] = ['in',$ids];
  57. }
  58. elseif(!empty($data)){
  59. $where['vod_id'] = ['gt', $data];
  60. }
  61. $col = 'vod';
  62. $order = 'vod_id asc';
  63. $fun = 'mac_url_vod_detail';
  64. $res = model('Vod')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  65. break;
  66. case 2:
  67. $where['art_status'] = ['eq',1];
  68. if($ac2=='today'){
  69. $where['art_'.$col_time] = ['gt',$today];
  70. }
  71. if(!empty($ids)){
  72. $where['art_id'] = ['in',$ids];
  73. }
  74. elseif(!empty($data)){
  75. $where['art_id'] = ['gt', $data];
  76. }
  77. $col = 'art';
  78. $order = 'art_id asc';
  79. $fun = 'mac_url_art_detail';
  80. $res = model('Art')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  81. break;
  82. case 3:
  83. $where['topic_status'] = ['eq',1];
  84. if($ac2=='today'){
  85. $where['topic_'.$col_time] = ['gt',$today];
  86. }
  87. if(!empty($ids)){
  88. $where['topic_id'] = ['in',$ids];
  89. }
  90. elseif(!empty($data)){
  91. $where['topic_id'] = ['gt', $data];
  92. }
  93. $col = 'topic';
  94. $order = 'topic_id asc';
  95. $fun = 'mac_url_topic_detail';
  96. $res = model('Topic')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  97. break;
  98. case 8:
  99. $where['actor_status'] = ['eq',1];
  100. if($ac2=='today'){
  101. $where['actor_'.$col_time] = ['gt',$today];
  102. }
  103. if(!empty($ids)){
  104. $where['actor_id'] = ['in',$ids];
  105. }
  106. elseif(!empty($data)){
  107. $where['actor_id'] = ['gt', $data];
  108. }
  109. $col = 'actor';
  110. $order = 'actor_id asc';
  111. $fun = 'mac_url_actor_detail';
  112. $res = model('Actor')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  113. break;
  114. case 9:
  115. $where['role_status'] = ['eq',1];
  116. if($ac2=='today'){
  117. $where['role_'.$col_time] = ['gt',$today];
  118. }
  119. if(!empty($ids)){
  120. $where['role_id'] = ['in',$ids];
  121. }
  122. elseif(!empty($data)){
  123. $where['role_id'] = ['gt', $data];
  124. }
  125. $col = 'role';
  126. $order = 'role_id asc';
  127. $fun = 'mac_url_role_detail';
  128. $res = model('Role')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  129. break;
  130. case 11:
  131. $where['website_status'] = ['eq',1];
  132. if($ac2=='today'){
  133. $where['website_'.$col_time] = ['gt',$today];
  134. }
  135. if(!empty($ids)){
  136. $where['website_id'] = ['in',$ids];
  137. }
  138. elseif(!empty($data)){
  139. $where['website_id'] = ['gt', $data];
  140. }
  141. $col = 'website';
  142. $order = 'website_id asc';
  143. $fun = 'mac_url_website_detail';
  144. $res = model('Website')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  145. break;
  146. case 12:
  147. $where['manga_status'] = ['eq',1];
  148. if($ac2=='today'){
  149. $where['manga_'.$col_time] = ['gt',$today];
  150. }
  151. if(!empty($ids)){
  152. $where['manga_id'] = ['in',$ids];
  153. }
  154. elseif(!empty($data)){
  155. $where['manga_id'] = ['gt', $data];
  156. }
  157. $col = 'manga';
  158. $order = 'manga_id asc';
  159. $fun = 'mac_url_manga_detail';
  160. $res = model('Manga')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  161. break;
  162. }
  163. if(empty($res['list'])){
  164. mac_echo(lang('admin/urlsend/no_data'));
  165. return;
  166. }
  167. mac_echo(lang('admin/urlsend/tip',[$res['total'],$res['pagecount'],$res['page']]));
  168. $urls = [];
  169. foreach($res['list'] as $k=>$v){
  170. $urls[$v[$col.'_id']] = $GLOBALS['http_type'] . $GLOBALS['config']['site']['site_url'] . $fun($v);
  171. $this->_lastid = $v[$col.'_id'];
  172. mac_echo($v[$col.'_id'] . '、'. $v[$col . '_name'] . '&nbsp;<a href="'.$urls[$v[$col.'_id']].'">'.$urls[$v[$col.'_id']].'</a>');
  173. }
  174. $res['urls'] = $urls;
  175. return $res;
  176. }
  177. public function push($pp=[])
  178. {
  179. if(!empty($pp)){
  180. $this->_param = $pp;
  181. }
  182. $ac = $this->_param['ac'];
  183. $cp = 'app\\common\\extend\\urlsend\\' . ucfirst($ac);
  184. if (class_exists($cp)) {
  185. $data = $this->data();
  186. $c = new $cp;
  187. $res = $c->submit($data);
  188. if($res['code']!=1){
  189. mac_echo($res['msg']);
  190. die;
  191. }
  192. if ($data['page'] >= $data['pagecount']) {
  193. mac_echo(lang('admin/urlsend/complete'));
  194. if(ENTRANCE=='admin') {
  195. }
  196. }
  197. else {
  198. $this->_param['page']++;
  199. $url = url('urlsend/push') . '?' . http_build_query($this->_param);
  200. if(ENTRANCE=='admin') {
  201. mac_jump($url, 3);
  202. }
  203. else{
  204. $this->push($this->_param);
  205. }
  206. }
  207. }
  208. else{
  209. $this->error(lang('param_err'));
  210. }
  211. }
  212. }