Urlsend.php 7.2 KB

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