Collect.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. use think\Cache;
  5. class Collect extends Base
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. //header('X-Accel-Buffering: no');
  11. }
  12. public function index()
  13. {
  14. $config = config('maccms');
  15. if (empty($config['collect']['manga'])) {
  16. $config['collect']['manga'] = [
  17. 'status' => '0',
  18. 'hits_start' => '',
  19. 'hits_end' => '',
  20. 'updown_start' => '',
  21. 'updown_end' => '',
  22. 'score' => '0',
  23. 'pic' => '0',
  24. 'psernd' => '0',
  25. 'psesyn' => '0',
  26. 'filter' => '',
  27. 'thesaurus' => '',
  28. 'words' => '',
  29. 'inrule' => ',a',
  30. 'uprule' => ',a',
  31. ];
  32. mac_arr2file(APP_PATH . 'extra/maccms.php', $config);
  33. }
  34. $param = input();
  35. $param['page'] = intval($param['page']) < 1 ? 1 : $param['page'];
  36. $param['limit'] = intval($param['limit']) < 1 ? 100 : $param['limit'];
  37. $where = [];
  38. $order = 'collect_id desc';
  39. $res = model('Collect')->listData($where, $order, $param['page'], $param['limit']);
  40. $this->assign('list', $res['list']);
  41. $this->assign('total', $res['total']);
  42. $this->assign('page', $res['page']);
  43. $this->assign('limit', $res['limit']);
  44. $param['page'] = '{page}';
  45. $param['limit'] = '{limit}';
  46. $this->assign('param', $param);
  47. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_vod';
  48. $collect_break_vod = Cache::get($key);
  49. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_art';
  50. $collect_break_art = Cache::get($key);
  51. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_actor';
  52. $collect_break_actor = Cache::get($key);
  53. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_role';
  54. $collect_break_role = Cache::get($key);
  55. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_website';
  56. $collect_break_website = Cache::get($key);
  57. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_manga';
  58. $collect_break_manga = Cache::get($key);
  59. $this->assign('collect_break_vod', $collect_break_vod);
  60. $this->assign('collect_break_art', $collect_break_art);
  61. $this->assign('collect_break_actor', $collect_break_actor);
  62. $this->assign('collect_break_role', $collect_break_role);
  63. $this->assign('collect_break_website', $collect_break_website);
  64. $this->assign('collect_break_manga', $collect_break_manga);
  65. $this->assign('title',lang('admin/collect/title'));
  66. return $this->fetch('admin@collect/index');
  67. }
  68. public function test()
  69. {
  70. $param = input();
  71. $res = model('Collect')->vod($param);
  72. return json($res);
  73. }
  74. public function info()
  75. {
  76. if (Request()->isPost()) {
  77. $param = input('post.');
  78. $validate = \think\Loader::validate('Token');
  79. if(!$validate->check($param)){
  80. return $this->error($validate->getError());
  81. }
  82. $res = model('Collect')->saveData($param);
  83. if ($res['code'] > 1) {
  84. return $this->error($res['msg']);
  85. }
  86. return $this->success($res['msg']);
  87. }
  88. $id = input('id');
  89. $where = [];
  90. $where['collect_id'] = ['eq', $id];
  91. $res = model('Collect')->infoData($where);
  92. $this->assign('info', $res['info']);
  93. $this->assign('title', lang('admin/collect/title'));
  94. return $this->fetch('admin@collect/info');
  95. }
  96. public function del()
  97. {
  98. $param = input();
  99. $ids = $param['ids'];
  100. if (!empty($ids)) {
  101. $where = [];
  102. $where['collect_id'] = ['in', $ids];
  103. $res = model('Collect')->delData($where);
  104. if ($res['code'] > 1) {
  105. return $this->error($res['msg']);
  106. }
  107. return $this->success($res['msg']);
  108. }
  109. return $this->error(lang('param_err'));
  110. }
  111. public function union()
  112. {
  113. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_vod';
  114. $collect_break_vod = Cache::get($key);
  115. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_art';
  116. $collect_break_art = Cache::get($key);
  117. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_actor';
  118. $collect_break_actor = Cache::get($key);
  119. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_role';
  120. $collect_break_role = Cache::get($key);
  121. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_website';
  122. $collect_break_website = Cache::get($key);
  123. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_manga';
  124. $collect_break_manga = Cache::get($key);
  125. $this->assign('collect_break_vod', $collect_break_vod);
  126. $this->assign('collect_break_art', $collect_break_art);
  127. $this->assign('collect_break_actor', $collect_break_actor);
  128. $this->assign('collect_break_role', $collect_break_role);
  129. $this->assign('collect_break_website', $collect_break_website);
  130. $this->assign('collect_break_manga', $collect_break_manga);
  131. $this->assign('title', lang('admin/collect/title'));
  132. return $this->fetch('admin@collect/union');
  133. }
  134. public function load()
  135. {
  136. $param = input();
  137. $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_' . $param['flag'];
  138. $collect_break = Cache::get($key);
  139. $url = $this->_ref;
  140. if (!empty($collect_break)) {
  141. echo lang('admin/collect/load_break');
  142. $url = $collect_break;
  143. }
  144. mac_jump($url);
  145. }
  146. public function api($pp = [])
  147. {
  148. $param = input();
  149. if (!empty($pp)) {
  150. $param = $pp;
  151. }
  152. //分类
  153. $type_list = model('Type')->getCache('type_list');
  154. $this->assign('type_list', $type_list);
  155. if (!empty($param['pg'])) {
  156. $param['page'] = $param['pg'];
  157. unset($param['pg']);
  158. }
  159. @session_write_close();
  160. if ($param['mid'] == '' || $param['mid'] == '1') {
  161. return $this->vod($param);
  162. } elseif ($param['mid'] == '2') {
  163. return $this->art($param);
  164. } elseif ($param['mid'] == '8') {
  165. return $this->actor($param);
  166. }
  167. elseif ($param['mid'] == '9') {
  168. return $this->role($param);
  169. }
  170. elseif ($param['mid'] == '11') {
  171. return $this->website($param);
  172. }
  173. elseif ($param['mid'] == '12') {
  174. return $this->manga($param);
  175. }
  176. }
  177. public function timing()
  178. {
  179. //当日视频分类ids
  180. $res = model('Vod')->updateToday('type');
  181. $this->assign('vod_type_ids_today', $res['data']);
  182. return $this->fetch('admin@collect/timing');
  183. }
  184. public function clearbind()
  185. {
  186. $param = input();
  187. $config = [];
  188. if(!empty($param['cjflag'])){
  189. $bind_list = config('bind');
  190. foreach($bind_list as $k=>$v){
  191. if(strpos($k,$param['cjflag'])===false){
  192. $config[$k] = $v;
  193. }
  194. }
  195. }
  196. $res = mac_arr2file( APP_PATH .'extra/bind.php', $config);
  197. if($res===false){
  198. return json(['code'=>0,'msg'=>lang('clear_err')]);
  199. }
  200. return json(['code'=>1,'msg'=>lang('clear_ok')]);
  201. }
  202. public function bind()
  203. {
  204. $param = input();
  205. $ids = $param['ids'];
  206. $col = $param['col'];
  207. $val = $param['val'];
  208. if(!empty($col)){
  209. $config = config('bind');
  210. $config[$col] = intval($val);
  211. $data = [];
  212. $data['id'] = $col;
  213. $data['st'] = 0;
  214. $data['local_type_id'] = $val;
  215. $data['local_type_name'] = '';
  216. if(intval($val)>0){
  217. $data['st'] = 1;
  218. $type_list = model('Type')->getCache('type_list');
  219. $data['local_type_name'] = $type_list[$val]['type_name'];
  220. }
  221. $res = mac_arr2file( APP_PATH .'extra/bind.php', $config);
  222. if($res===false){
  223. return $this->error(lang('save_err'));
  224. }
  225. return $this->success(lang('save_ok'),null, $data);
  226. }
  227. return $this->error(lang('param_err'));
  228. }
  229. public function vod($param)
  230. {
  231. if($param['ac'] != 'list'){
  232. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_vod';
  233. Cache::set($key, url('collect/api').'?'. http_build_query($param) );
  234. }
  235. $res = model('Collect')->vod($param);
  236. if($res['code']>1){
  237. return $this->error($res['msg']);
  238. }
  239. if($param['ac'] == 'list'){
  240. $bind_list = config('bind');
  241. $type_list = model('Type')->getCache('type_list');
  242. foreach($res['type'] as $k=>$v){
  243. $key = $param['cjflag'] . '_' . $v['type_id'];
  244. $res['type'][$k]['isbind'] = 0;
  245. $local_id = intval($bind_list[$key]);
  246. if( $local_id>0 ){
  247. $res['type'][$k]['isbind'] = 1;
  248. $res['type'][$k]['local_type_id'] = $local_id;
  249. $type_name = $type_list[$local_id]['type_name'];
  250. if(empty($type_name)){
  251. $type_name = lang('unknown_type');
  252. }
  253. $res['type'][$k]['local_type_name'] = $type_name;
  254. }
  255. }
  256. $this->assign('page',$res['page']);
  257. $this->assign('type',$res['type']);
  258. $this->assign('list',$res['data']);
  259. $this->assign('total',$res['page']['recordcount']);
  260. $this->assign('page',$res['page']['page']);
  261. $this->assign('limit',$res['page']['pagesize']);
  262. $param['page'] = '{page}';
  263. $param['limit'] = '{limit}';
  264. $this->assign('param',$param);
  265. $this->assign('param_str',http_build_query($param)) ;
  266. return $this->fetch('admin@collect/vod');
  267. }
  268. $page_now = isset($param['page']) && strlen($param['page']) > 0 ? (int)$param['page'] : 1;
  269. mac_echo('<title>' . $page_now . '/' . (int)$res['page']['pagecount'] . ' collecting..</title>');
  270. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  271. model('Collect')->vod_data($param,$res );
  272. }
  273. public function art($param)
  274. {
  275. if($param['ac'] != 'list'){
  276. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_art';
  277. Cache::set($key, url('collect/api').'?'. http_build_query($param) );
  278. }
  279. $res = model('Collect')->art($param);
  280. if($res['code']>1){
  281. return $this->error($res['msg']);
  282. }
  283. if($param['ac'] == 'list'){
  284. $bind_list = config('bind');
  285. $type_list = model('Type')->getCache('type_list');
  286. foreach($res['type'] as $k=>$v){
  287. $key = $param['cjflag'] . '_' . $v['type_id'];
  288. $res['type'][$k]['isbind'] = 0;
  289. $local_id = intval($bind_list[$key]);
  290. if( $local_id>0 ){
  291. $res['type'][$k]['isbind'] = 1;
  292. $res['type'][$k]['local_type_id'] = $local_id;
  293. $type_name = $type_list[$local_id]['type_name'];
  294. if(empty($type_name)){
  295. $type_name = lang('unknown_type');
  296. }
  297. $res['type'][$k]['local_type_name'] = $type_name;
  298. }
  299. }
  300. $this->assign('page',$res['page']);
  301. $this->assign('type',$res['type']);
  302. $this->assign('list',$res['data']);
  303. $this->assign('total',$res['page']['recordcount']);
  304. $this->assign('page',$res['page']['page']);
  305. $this->assign('limit',$res['page']['pagesize']);
  306. $param['page'] = '{page}';
  307. $param['limit'] = '{limit}';
  308. $this->assign('param',$param);
  309. $this->assign('param_str',http_build_query($param)) ;
  310. return $this->fetch('admin@collect/art');
  311. }
  312. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  313. model('Collect')->art_data($param,$res );
  314. }
  315. public function actor($param)
  316. {
  317. if($param['ac'] != 'list'){
  318. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_actor';
  319. Cache::set($key, url('collect/api').'?'. http_build_query($param) );
  320. }
  321. $res = model('Collect')->actor($param);
  322. if($res['code']>1){
  323. return $this->error($res['msg']);
  324. }
  325. if($param['ac'] == 'list'){
  326. $bind_list = config('bind');
  327. $type_list = model('Type')->getCache('type_list');
  328. foreach($res['type'] as $k=>$v){
  329. $key = $param['cjflag'] . '_' . $v['type_id'];
  330. $res['type'][$k]['isbind'] = 0;
  331. $local_id = intval($bind_list[$key]);
  332. if( $local_id>0 ){
  333. $res['type'][$k]['isbind'] = 1;
  334. $res['type'][$k]['local_type_id'] = $local_id;
  335. $type_name = $type_list[$local_id]['type_name'];
  336. if(empty($type_name)){
  337. $type_name = lang('unknown_type');
  338. }
  339. $res['type'][$k]['local_type_name'] = $type_name;
  340. }
  341. }
  342. $this->assign('page',$res['page']);
  343. $this->assign('type',$res['type']);
  344. $this->assign('list',$res['data']);
  345. $this->assign('total',$res['page']['recordcount']);
  346. $this->assign('page',$res['page']['page']);
  347. $this->assign('limit',$res['page']['pagesize']);
  348. $param['page'] = '{page}';
  349. $param['limit'] = '{limit}';
  350. $this->assign('param',$param);
  351. $this->assign('param_str',http_build_query($param)) ;
  352. return $this->fetch('admin@collect/actor');
  353. }
  354. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  355. model('Collect')->actor_data($param,$res );
  356. }
  357. public function role($param)
  358. {
  359. if ($param['ac'] != 'list') {
  360. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_role';
  361. Cache::set($key, url('collect/api') . '?' . http_build_query($param));
  362. }
  363. $res = model('Collect')->role($param);
  364. if ($res['code'] > 1) {
  365. return $this->error($res['msg']);
  366. }
  367. if ($param['ac'] == 'list') {
  368. $bind_list = config('bind');
  369. $type_list = model('Type')->getCache('type_list');
  370. foreach ($res['type'] as $k => $v) {
  371. $key = $param['cjflag'] . '_' . $v['type_id'];
  372. $res['type'][$k]['isbind'] = 0;
  373. $local_id = intval($bind_list[$key]);
  374. if ($local_id > 0) {
  375. $res['type'][$k]['isbind'] = 1;
  376. $res['type'][$k]['local_type_id'] = $local_id;
  377. $type_name = $type_list[$local_id]['type_name'];
  378. if (empty($type_name)) {
  379. $type_name = lang('unknown_type');
  380. }
  381. $res['type'][$k]['local_type_name'] = $type_name;
  382. }
  383. }
  384. $this->assign('page', $res['page']);
  385. $this->assign('type', $res['type']);
  386. $this->assign('list', $res['data']);
  387. $this->assign('total', $res['page']['recordcount']);
  388. $this->assign('page', $res['page']['page']);
  389. $this->assign('limit', $res['page']['pagesize']);
  390. $param['page'] = '{page}';
  391. $param['limit'] = '{limit}';
  392. $this->assign('param', $param);
  393. $this->assign('param_str', http_build_query($param));
  394. return $this->fetch('admin@collect/role');
  395. }
  396. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  397. model('Collect')->role_data($param,$res );
  398. }
  399. public function website($param)
  400. {
  401. if ($param['ac'] != 'list') {
  402. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_website';
  403. Cache::set($key, url('collect/api') . '?' . http_build_query($param));
  404. }
  405. $res = model('Collect')->website($param);
  406. if ($res['code'] > 1) {
  407. return $this->error($res['msg']);
  408. }
  409. if ($param['ac'] == 'list') {
  410. $bind_list = config('bind');
  411. $type_list = model('Type')->getCache('type_list');
  412. foreach ($res['type'] as $k => $v) {
  413. $key = $param['cjflag'] . '_' . $v['type_id'];
  414. $res['type'][$k]['isbind'] = 0;
  415. $local_id = intval($bind_list[$key]);
  416. if ($local_id > 0) {
  417. $res['type'][$k]['isbind'] = 1;
  418. $res['type'][$k]['local_type_id'] = $local_id;
  419. $type_name = $type_list[$local_id]['type_name'];
  420. if (empty($type_name)) {
  421. $type_name = lang('unknown_type');
  422. }
  423. $res['type'][$k]['local_type_name'] = $type_name;
  424. }
  425. }
  426. $this->assign('page', $res['page']);
  427. $this->assign('type', $res['type']);
  428. $this->assign('list', $res['data']);
  429. $this->assign('total', $res['page']['recordcount']);
  430. $this->assign('page', $res['page']['page']);
  431. $this->assign('limit', $res['page']['pagesize']);
  432. $param['page'] = '{page}';
  433. $param['limit'] = '{limit}';
  434. $this->assign('param', $param);
  435. $this->assign('param_str', http_build_query($param));
  436. return $this->fetch('admin@collect/website');
  437. }
  438. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  439. model('Collect')->website_data($param,$res );
  440. }
  441. public function manga($param)
  442. {
  443. if($param['ac'] != 'list'){
  444. $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_manga';
  445. Cache::set($key, url('collect/api').'?'. http_build_query($param) );
  446. }
  447. $res = model('Collect')->manga($param);
  448. if($res['code']>1){
  449. return $this->error($res['msg']);
  450. }
  451. if($param['ac'] == 'list'){
  452. $bind_list = config('bind');
  453. $type_list = model('Type')->getCache('type_list');
  454. $manga_type_list = [];
  455. foreach($type_list as $k=>$v){
  456. if($v['type_mid'] == 12){
  457. $manga_type_list[$k] = $v;
  458. }
  459. }
  460. $this->assign('type_list', $manga_type_list);
  461. foreach($res['type'] as $k=>$v){
  462. $key = $param['cjflag'] . '_' . $v['type_id'];
  463. $res['type'][$k]['isbind'] = 0;
  464. $local_id = intval($bind_list[$key]);
  465. if( $local_id>0 ){
  466. $res['type'][$k]['isbind'] = 1;
  467. $res['type'][$k]['local_type_id'] = $local_id;
  468. $type_name = $manga_type_list[$local_id]['type_name'];
  469. if(empty($type_name)){
  470. $type_name = lang('unknown_type');
  471. }
  472. $res['type'][$k]['local_type_name'] = $type_name;
  473. }
  474. }
  475. $this->assign('page',$res['page']);
  476. $this->assign('type',$res['type']);
  477. $this->assign('list',$res['data']);
  478. $this->assign('total',$res['page']['recordcount']);
  479. $this->assign('page',$res['page']['page']);
  480. $this->assign('limit',$res['page']['pagesize']);
  481. $param['page'] = '{page}';
  482. $param['limit'] = '{limit}';
  483. $this->assign('param',$param);
  484. $this->assign('param_str',http_build_query($param)) ;
  485. return $this->fetch('admin@collect/manga');
  486. }
  487. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  488. model('Collect')->manga_data($param,$res );
  489. }
  490. }