Urlsend.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. $today = strtotime(date('Y-m-d'));
  41. $where = [];
  42. $col = '';
  43. switch($mid)
  44. {
  45. case 1:
  46. $where['vod_status'] = ['eq',1];
  47. if($ac2=='today'){
  48. $where['vod_time'] = ['gt',$today];
  49. }
  50. if(!empty($ids)){
  51. $where['vod_id'] = ['in',$ids];
  52. }
  53. elseif(!empty($data)){
  54. $where['vod_id'] = ['gt', $data];
  55. }
  56. $col = 'vod';
  57. $order = 'vod_id asc';
  58. $fun = 'mac_url_vod_detail';
  59. $res = model('Vod')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  60. break;
  61. case 2:
  62. $where['art_status'] = ['eq',1];
  63. if($ac2=='today'){
  64. $where['art_time_add'] = ['gt',$today];
  65. }
  66. if(!empty($ids)){
  67. $where['art_id'] = ['in',$ids];
  68. }
  69. elseif(!empty($data)){
  70. $where['art_id'] = ['gt', $data];
  71. }
  72. $col = 'art';
  73. $order = 'art_id asc';
  74. $fun = 'mac_url_art_detail';
  75. $res = model('Art')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  76. break;
  77. case 3:
  78. $where['topic_status'] = ['eq',1];
  79. if($ac2=='today'){
  80. $where['topic_time_add'] = ['gt',$today];
  81. }
  82. if(!empty($ids)){
  83. $where['topic_id'] = ['in',$ids];
  84. }
  85. elseif(!empty($data)){
  86. $where['topic_id'] = ['gt', $data];
  87. }
  88. $col = 'topic';
  89. $order = 'topic_id asc';
  90. $fun = 'mac_url_topic_detail';
  91. $res = model('Topic')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  92. break;
  93. case 8:
  94. $where['actor_status'] = ['eq',1];
  95. if($ac2=='today'){
  96. $where['actor_time_add'] = ['gt',$today];
  97. }
  98. if(!empty($ids)){
  99. $where['actor_id'] = ['in',$ids];
  100. }
  101. elseif(!empty($data)){
  102. $where['actor_id'] = ['gt', $data];
  103. }
  104. $col = 'actor';
  105. $order = 'actor_id asc';
  106. $fun = 'mac_url_actor_detail';
  107. $res = model('Actor')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  108. break;
  109. case 9:
  110. $where['role_status'] = ['eq',1];
  111. if($ac2=='today'){
  112. $where['role_time_add'] = ['gt',$today];
  113. }
  114. if(!empty($ids)){
  115. $where['role_id'] = ['in',$ids];
  116. }
  117. elseif(!empty($data)){
  118. $where['role_id'] = ['gt', $data];
  119. }
  120. $col = 'role';
  121. $order = 'role_id asc';
  122. $fun = 'mac_url_role_detail';
  123. $res = model('Role')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  124. break;
  125. case 11:
  126. $where['website_status'] = ['eq',1];
  127. if($ac2=='today'){
  128. $where['website_time_add'] = ['gt',$today];
  129. }
  130. if(!empty($ids)){
  131. $where['website_id'] = ['in',$ids];
  132. }
  133. elseif(!empty($data)){
  134. $where['website_id'] = ['gt', $data];
  135. }
  136. $col = 'website';
  137. $order = 'website_id asc';
  138. $fun = 'mac_url_website_detail';
  139. $res = model('Website')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
  140. break;
  141. }
  142. if(empty($res['list'])){
  143. mac_echo(lang('admin/urlsend/no_data'));
  144. return;
  145. }
  146. mac_echo(lang('admin/urlsend/tip',[$res['total'],$res['pagecount'],$res['page']]));
  147. $urls = [];
  148. foreach($res['list'] as $k=>$v){
  149. $urls[$v[$col.'_id']] = $GLOBALS['http_type'] . $GLOBALS['config']['site']['site_url'] . $fun($v);
  150. $this->_lastid = $v[$col.'_id'];
  151. mac_echo($v[$col.'_id'] . '、'. $v[$col . '_name'] . '&nbsp;<a href="'.$urls[$v[$col.'_id']].'">'.$urls[$v[$col.'_id']].'</a>');
  152. }
  153. $res['urls'] = $urls;
  154. return $res;
  155. }
  156. public function push($pp=[])
  157. {
  158. if(!empty($pp)){
  159. $this->_param = $pp;
  160. }
  161. $ac = $this->_param['ac'];
  162. $cp = 'app\\common\\extend\\urlsend\\' . ucfirst($ac);
  163. if (class_exists($cp)) {
  164. $data = $this->data();
  165. $c = new $cp;
  166. $res = $c->submit($data);
  167. if($res['code']!=1){
  168. mac_echo($res['msg']);
  169. die;
  170. }
  171. if ($data['page'] >= $data['pagecount']) {
  172. mac_echo(lang('admin/urlsend/complete'));
  173. if(ENTRANCE=='admin') {
  174. }
  175. }
  176. else {
  177. $this->_param['page']++;
  178. $url = url('urlsend/push') . '?' . http_build_query($this->_param);
  179. if(ENTRANCE=='admin') {
  180. mac_jump($url, 3);
  181. }
  182. else{
  183. $this->push($this->_param);
  184. }
  185. }
  186. }
  187. else{
  188. $this->error(lang('param_err'));
  189. }
  190. }
  191. }