| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581 |
- <?php
- namespace app\admin\controller;
- use think\Db;
- use think\Cache;
- class Collect extends Base
- {
- public function __construct()
- {
- parent::__construct();
- //header('X-Accel-Buffering: no');
- }
- public function index()
- {
- $config = config('maccms');
- if (empty($config['collect']['manga'])) {
- $config['collect']['manga'] = [
- 'status' => '0',
- 'hits_start' => '',
- 'hits_end' => '',
- 'updown_start' => '',
- 'updown_end' => '',
- 'score' => '0',
- 'pic' => '0',
- 'psernd' => '0',
- 'psesyn' => '0',
- 'filter' => '',
- 'thesaurus' => '',
- 'words' => '',
- 'inrule' => ',a',
- 'uprule' => ',a',
- ];
- mac_arr2file(APP_PATH . 'extra/maccms.php', $config);
- }
- $param = input();
- $param['page'] = intval($param['page']) < 1 ? 1 : $param['page'];
- $param['limit'] = intval($param['limit']) < 1 ? 100 : $param['limit'];
- $where = [];
- $order = 'collect_id desc';
- $res = model('Collect')->listData($where, $order, $param['page'], $param['limit']);
- $this->assign('list', $res['list']);
- $this->assign('total', $res['total']);
- $this->assign('page', $res['page']);
- $this->assign('limit', $res['limit']);
- $param['page'] = '{page}';
- $param['limit'] = '{limit}';
- $this->assign('param', $param);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_vod';
- $collect_break_vod = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_art';
- $collect_break_art = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_actor';
- $collect_break_actor = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_role';
- $collect_break_role = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_website';
- $collect_break_website = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_manga';
- $collect_break_manga = Cache::get($key);
- $this->assign('collect_break_vod', $collect_break_vod);
- $this->assign('collect_break_art', $collect_break_art);
- $this->assign('collect_break_actor', $collect_break_actor);
- $this->assign('collect_break_role', $collect_break_role);
- $this->assign('collect_break_website', $collect_break_website);
- $this->assign('collect_break_manga', $collect_break_manga);
- $this->assign('title',lang('admin/collect/title'));
- return $this->fetch('admin@collect/index');
- }
- public function test()
- {
- $param = input();
- $res = model('Collect')->vod($param);
- return json($res);
- }
- public function info()
- {
- if (Request()->isPost()) {
- $param = input('post.');
- $validate = \think\Loader::validate('Token');
- if(!$validate->check($param)){
- return $this->error($validate->getError());
- }
- $res = model('Collect')->saveData($param);
- if ($res['code'] > 1) {
- return $this->error($res['msg']);
- }
- return $this->success($res['msg']);
- }
- $id = input('id');
- $where = [];
- $where['collect_id'] = ['eq', $id];
- $res = model('Collect')->infoData($where);
- $this->assign('info', $res['info']);
- $this->assign('title', lang('admin/collect/title'));
- return $this->fetch('admin@collect/info');
- }
- public function del()
- {
- $param = input();
- $ids = $param['ids'];
- if (!empty($ids)) {
- $where = [];
- $where['collect_id'] = ['in', $ids];
- $res = model('Collect')->delData($where);
- if ($res['code'] > 1) {
- return $this->error($res['msg']);
- }
- return $this->success($res['msg']);
- }
- return $this->error(lang('param_err'));
- }
- public function union()
- {
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_vod';
- $collect_break_vod = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_art';
- $collect_break_art = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_actor';
- $collect_break_actor = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_role';
- $collect_break_role = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_website';
- $collect_break_website = Cache::get($key);
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_manga';
- $collect_break_manga = Cache::get($key);
- $this->assign('collect_break_vod', $collect_break_vod);
- $this->assign('collect_break_art', $collect_break_art);
- $this->assign('collect_break_actor', $collect_break_actor);
- $this->assign('collect_break_role', $collect_break_role);
- $this->assign('collect_break_website', $collect_break_website);
- $this->assign('collect_break_manga', $collect_break_manga);
- $this->assign('title', lang('admin/collect/title'));
- return $this->fetch('admin@collect/union');
- }
- public function load()
- {
- $param = input();
- $key = $GLOBALS['config']['app']['cache_flag']. '_'. 'collect_break_' . $param['flag'];
- $collect_break = Cache::get($key);
- $url = $this->_ref;
- if (!empty($collect_break)) {
- echo lang('admin/collect/load_break');
- $url = $collect_break;
- }
- mac_jump($url);
- }
- public function api($pp = [])
- {
- $param = input();
- if (!empty($pp)) {
- $param = $pp;
- }
- //分类
- $type_list = model('Type')->getCache('type_list');
- $this->assign('type_list', $type_list);
- if (!empty($param['pg'])) {
- $param['page'] = $param['pg'];
- unset($param['pg']);
- }
- @session_write_close();
-
- if ($param['mid'] == '' || $param['mid'] == '1') {
- return $this->vod($param);
- } elseif ($param['mid'] == '2') {
- return $this->art($param);
- } elseif ($param['mid'] == '8') {
- return $this->actor($param);
- }
- elseif ($param['mid'] == '9') {
- return $this->role($param);
- }
- elseif ($param['mid'] == '11') {
- return $this->website($param);
- }
- elseif ($param['mid'] == '12') {
- return $this->manga($param);
- }
- }
- public function timing()
- {
- //当日视频分类ids
- $res = model('Vod')->updateToday('type');
- $this->assign('vod_type_ids_today', $res['data']);
- return $this->fetch('admin@collect/timing');
- }
- public function clearbind()
- {
- $param = input();
- $config = [];
- if(!empty($param['cjflag'])){
- $bind_list = config('bind');
- foreach($bind_list as $k=>$v){
- if(strpos($k,$param['cjflag'])===false){
- $config[$k] = $v;
- }
- }
- }
- $res = mac_arr2file( APP_PATH .'extra/bind.php', $config);
- if($res===false){
- return json(['code'=>0,'msg'=>lang('clear_err')]);
- }
- return json(['code'=>1,'msg'=>lang('clear_ok')]);
- }
- public function bind()
- {
- $param = input();
- $ids = $param['ids'];
- $col = $param['col'];
- $val = $param['val'];
- if(!empty($col)){
- $config = config('bind');
- $config[$col] = intval($val);
- $data = [];
- $data['id'] = $col;
- $data['st'] = 0;
- $data['local_type_id'] = $val;
- $data['local_type_name'] = '';
- if(intval($val)>0){
- $data['st'] = 1;
- $type_list = model('Type')->getCache('type_list');
- $data['local_type_name'] = $type_list[$val]['type_name'];
- }
- $res = mac_arr2file( APP_PATH .'extra/bind.php', $config);
- if($res===false){
- return $this->error(lang('save_err'));
- }
- return $this->success(lang('save_ok'),null, $data);
- }
- return $this->error(lang('param_err'));
- }
- public function vod($param)
- {
- if($param['ac'] != 'list'){
- $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_vod';
- Cache::set($key, url('collect/api').'?'. http_build_query($param) );
- }
- $res = model('Collect')->vod($param);
- if($res['code']>1){
- return $this->error($res['msg']);
- }
- if($param['ac'] == 'list'){
- $bind_list = config('bind');
- $type_list = model('Type')->getCache('type_list');
- foreach($res['type'] as $k=>$v){
- $key = $param['cjflag'] . '_' . $v['type_id'];
- $res['type'][$k]['isbind'] = 0;
- $local_id = intval($bind_list[$key]);
- if( $local_id>0 ){
- $res['type'][$k]['isbind'] = 1;
- $res['type'][$k]['local_type_id'] = $local_id;
- $type_name = $type_list[$local_id]['type_name'];
- if(empty($type_name)){
- $type_name = lang('unknown_type');
- }
- $res['type'][$k]['local_type_name'] = $type_name;
- }
- }
- $this->assign('page',$res['page']);
- $this->assign('type',$res['type']);
- $this->assign('list',$res['data']);
- $this->assign('total',$res['page']['recordcount']);
- $this->assign('page',$res['page']['page']);
- $this->assign('limit',$res['page']['pagesize']);
- $param['page'] = '{page}';
- $param['limit'] = '{limit}';
- $this->assign('param',$param);
- $this->assign('param_str',http_build_query($param)) ;
- return $this->fetch('admin@collect/vod');
- }
- $page_now = isset($param['page']) && strlen($param['page']) > 0 ? (int)$param['page'] : 1;
- mac_echo('<title>' . $page_now . '/' . (int)$res['page']['pagecount'] . ' collecting..</title>');
- mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
- model('Collect')->vod_data($param,$res );
- }
- public function art($param)
- {
- if($param['ac'] != 'list'){
- $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_art';
- Cache::set($key, url('collect/api').'?'. http_build_query($param) );
- }
- $res = model('Collect')->art($param);
- if($res['code']>1){
- return $this->error($res['msg']);
- }
- if($param['ac'] == 'list'){
- $bind_list = config('bind');
- $type_list = model('Type')->getCache('type_list');
- foreach($res['type'] as $k=>$v){
- $key = $param['cjflag'] . '_' . $v['type_id'];
- $res['type'][$k]['isbind'] = 0;
- $local_id = intval($bind_list[$key]);
- if( $local_id>0 ){
- $res['type'][$k]['isbind'] = 1;
- $res['type'][$k]['local_type_id'] = $local_id;
- $type_name = $type_list[$local_id]['type_name'];
- if(empty($type_name)){
- $type_name = lang('unknown_type');
- }
- $res['type'][$k]['local_type_name'] = $type_name;
- }
- }
- $this->assign('page',$res['page']);
- $this->assign('type',$res['type']);
- $this->assign('list',$res['data']);
- $this->assign('total',$res['page']['recordcount']);
- $this->assign('page',$res['page']['page']);
- $this->assign('limit',$res['page']['pagesize']);
- $param['page'] = '{page}';
- $param['limit'] = '{limit}';
- $this->assign('param',$param);
- $this->assign('param_str',http_build_query($param)) ;
- return $this->fetch('admin@collect/art');
- }
- mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
- model('Collect')->art_data($param,$res );
- }
- public function actor($param)
- {
- if($param['ac'] != 'list'){
- $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_actor';
- Cache::set($key, url('collect/api').'?'. http_build_query($param) );
- }
- $res = model('Collect')->actor($param);
- if($res['code']>1){
- return $this->error($res['msg']);
- }
- if($param['ac'] == 'list'){
- $bind_list = config('bind');
- $type_list = model('Type')->getCache('type_list');
- foreach($res['type'] as $k=>$v){
- $key = $param['cjflag'] . '_' . $v['type_id'];
- $res['type'][$k]['isbind'] = 0;
- $local_id = intval($bind_list[$key]);
- if( $local_id>0 ){
- $res['type'][$k]['isbind'] = 1;
- $res['type'][$k]['local_type_id'] = $local_id;
- $type_name = $type_list[$local_id]['type_name'];
- if(empty($type_name)){
- $type_name = lang('unknown_type');
- }
- $res['type'][$k]['local_type_name'] = $type_name;
- }
- }
- $this->assign('page',$res['page']);
- $this->assign('type',$res['type']);
- $this->assign('list',$res['data']);
- $this->assign('total',$res['page']['recordcount']);
- $this->assign('page',$res['page']['page']);
- $this->assign('limit',$res['page']['pagesize']);
- $param['page'] = '{page}';
- $param['limit'] = '{limit}';
- $this->assign('param',$param);
- $this->assign('param_str',http_build_query($param)) ;
- return $this->fetch('admin@collect/actor');
- }
- mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
- model('Collect')->actor_data($param,$res );
- }
- public function role($param)
- {
- if ($param['ac'] != 'list') {
- $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_role';
- Cache::set($key, url('collect/api') . '?' . http_build_query($param));
- }
- $res = model('Collect')->role($param);
- if ($res['code'] > 1) {
- return $this->error($res['msg']);
- }
- if ($param['ac'] == 'list') {
- $bind_list = config('bind');
- $type_list = model('Type')->getCache('type_list');
- foreach ($res['type'] as $k => $v) {
- $key = $param['cjflag'] . '_' . $v['type_id'];
- $res['type'][$k]['isbind'] = 0;
- $local_id = intval($bind_list[$key]);
- if ($local_id > 0) {
- $res['type'][$k]['isbind'] = 1;
- $res['type'][$k]['local_type_id'] = $local_id;
- $type_name = $type_list[$local_id]['type_name'];
- if (empty($type_name)) {
- $type_name = lang('unknown_type');
- }
- $res['type'][$k]['local_type_name'] = $type_name;
- }
- }
- $this->assign('page', $res['page']);
- $this->assign('type', $res['type']);
- $this->assign('list', $res['data']);
- $this->assign('total', $res['page']['recordcount']);
- $this->assign('page', $res['page']['page']);
- $this->assign('limit', $res['page']['pagesize']);
- $param['page'] = '{page}';
- $param['limit'] = '{limit}';
- $this->assign('param', $param);
- $this->assign('param_str', http_build_query($param));
- return $this->fetch('admin@collect/role');
- }
- mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
- model('Collect')->role_data($param,$res );
- }
- public function website($param)
- {
- if ($param['ac'] != 'list') {
- $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_website';
- Cache::set($key, url('collect/api') . '?' . http_build_query($param));
- }
- $res = model('Collect')->website($param);
- if ($res['code'] > 1) {
- return $this->error($res['msg']);
- }
- if ($param['ac'] == 'list') {
- $bind_list = config('bind');
- $type_list = model('Type')->getCache('type_list');
- foreach ($res['type'] as $k => $v) {
- $key = $param['cjflag'] . '_' . $v['type_id'];
- $res['type'][$k]['isbind'] = 0;
- $local_id = intval($bind_list[$key]);
- if ($local_id > 0) {
- $res['type'][$k]['isbind'] = 1;
- $res['type'][$k]['local_type_id'] = $local_id;
- $type_name = $type_list[$local_id]['type_name'];
- if (empty($type_name)) {
- $type_name = lang('unknown_type');
- }
- $res['type'][$k]['local_type_name'] = $type_name;
- }
- }
- $this->assign('page', $res['page']);
- $this->assign('type', $res['type']);
- $this->assign('list', $res['data']);
- $this->assign('total', $res['page']['recordcount']);
- $this->assign('page', $res['page']['page']);
- $this->assign('limit', $res['page']['pagesize']);
- $param['page'] = '{page}';
- $param['limit'] = '{limit}';
- $this->assign('param', $param);
- $this->assign('param_str', http_build_query($param));
- return $this->fetch('admin@collect/website');
- }
- mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
- model('Collect')->website_data($param,$res );
- }
- public function manga($param)
- {
- if($param['ac'] != 'list'){
- $key = $GLOBALS['config']['app']['cache_flag']. '_'.'collect_break_manga';
- Cache::set($key, url('collect/api').'?'. http_build_query($param) );
- }
- $res = model('Collect')->manga($param);
- if($res['code']>1){
- return $this->error($res['msg']);
- }
- if($param['ac'] == 'list'){
- $bind_list = config('bind');
- $type_list = model('Type')->getCache('type_list');
- $manga_type_list = [];
- foreach($type_list as $k=>$v){
- if($v['type_mid'] == 12){
- $manga_type_list[$k] = $v;
- }
- }
- $this->assign('type_list', $manga_type_list);
- foreach($res['type'] as $k=>$v){
- $key = $param['cjflag'] . '_' . $v['type_id'];
- $res['type'][$k]['isbind'] = 0;
- $local_id = intval($bind_list[$key]);
- if( $local_id>0 ){
- $res['type'][$k]['isbind'] = 1;
- $res['type'][$k]['local_type_id'] = $local_id;
- $type_name = $manga_type_list[$local_id]['type_name'];
- if(empty($type_name)){
- $type_name = lang('unknown_type');
- }
- $res['type'][$k]['local_type_name'] = $type_name;
- }
- }
- $this->assign('page',$res['page']);
- $this->assign('type',$res['type']);
- $this->assign('list',$res['data']);
- $this->assign('total',$res['page']['recordcount']);
- $this->assign('page',$res['page']['page']);
- $this->assign('limit',$res['page']['pagesize']);
- $param['page'] = '{page}';
- $param['limit'] = '{limit}';
- $this->assign('param',$param);
- $this->assign('param_str',http_build_query($param)) ;
- return $this->fetch('admin@collect/manga');
- }
- mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
- model('Collect')->manga_data($param,$res );
- }
- }
|