| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <?php
- namespace app\admin\controller;
- class Urlsend extends Base
- {
- public $_lastid='';
- public $_param;
- public function __construct()
- {
- parent::__construct();
- $this->_param = input();
- }
- public function index()
- {
- if (Request()->isPost()) {
- $config = input();
- $config_new['urlsend'] = $config['urlsend'];
- $config_old = config('maccms');
- $config_new = array_merge($config_old, $config_new);
- $res = mac_arr2file(APP_PATH . 'extra/maccms.php', $config_new);
- if ($res === false) {
- return $this->error(lang('save_err'));
- }
- return $this->success(lang('save_ok'));
- }
- $urlsend_config = $GLOBALS['config']['urlsend'];
- $this->assign('config',$urlsend_config);
- $extends = mac_extends_list('urlsend');
- $this->assign('extends',$extends);
- $this->assign('title',lang('admin/urlsend/title'));
- return $this->fetch('admin@urlsend/index');
- }
- public function data()
- {
- mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
- $list = [];
- $mid = $this->_param['mid'];
- $this->_param['page'] = intval($this->_param['page']) <1 ? 1 : $this->_param['page'];
- $this->_param['limit'] = intval($this->_param['limit']) <1 ? 50 : $this->_param['limit'];
- $ids = $this->_param['ids'];
- $ac2 = $this->_param['ac2'];
- $col_time = 'time';
- if($this->_param['range'] == '1'){
- $col_time = 'time_add';
- }
- $today = strtotime(date('Y-m-d'));
- $where = [];
- $col = '';
- switch($mid)
- {
- case 1:
- $where['vod_status'] = ['eq',1];
- if($ac2=='today'){
- $where['vod_'.$col_time] = ['gt',$today];
- }
- if(!empty($ids)){
- $where['vod_id'] = ['in',$ids];
- }
- elseif(!empty($data)){
- $where['vod_id'] = ['gt', $data];
- }
- $col = 'vod';
- $order = 'vod_id asc';
- $fun = 'mac_url_vod_detail';
- $res = model('Vod')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
- break;
- case 2:
- $where['art_status'] = ['eq',1];
- if($ac2=='today'){
- $where['art_'.$col_time] = ['gt',$today];
- }
- if(!empty($ids)){
- $where['art_id'] = ['in',$ids];
- }
- elseif(!empty($data)){
- $where['art_id'] = ['gt', $data];
- }
- $col = 'art';
- $order = 'art_id asc';
- $fun = 'mac_url_art_detail';
- $res = model('Art')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
- break;
- case 3:
- $where['topic_status'] = ['eq',1];
- if($ac2=='today'){
- $where['topic_'.$col_time] = ['gt',$today];
- }
- if(!empty($ids)){
- $where['topic_id'] = ['in',$ids];
- }
- elseif(!empty($data)){
- $where['topic_id'] = ['gt', $data];
- }
- $col = 'topic';
- $order = 'topic_id asc';
- $fun = 'mac_url_topic_detail';
- $res = model('Topic')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
- break;
- case 8:
- $where['actor_status'] = ['eq',1];
- if($ac2=='today'){
- $where['actor_'.$col_time] = ['gt',$today];
- }
- if(!empty($ids)){
- $where['actor_id'] = ['in',$ids];
- }
- elseif(!empty($data)){
- $where['actor_id'] = ['gt', $data];
- }
- $col = 'actor';
- $order = 'actor_id asc';
- $fun = 'mac_url_actor_detail';
- $res = model('Actor')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
- break;
- case 9:
- $where['role_status'] = ['eq',1];
- if($ac2=='today'){
- $where['role_'.$col_time] = ['gt',$today];
- }
- if(!empty($ids)){
- $where['role_id'] = ['in',$ids];
- }
- elseif(!empty($data)){
- $where['role_id'] = ['gt', $data];
- }
- $col = 'role';
- $order = 'role_id asc';
- $fun = 'mac_url_role_detail';
- $res = model('Role')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
- break;
- case 11:
- $where['website_status'] = ['eq',1];
- if($ac2=='today'){
- $where['website_'.$col_time] = ['gt',$today];
- }
- if(!empty($ids)){
- $where['website_id'] = ['in',$ids];
- }
- elseif(!empty($data)){
- $where['website_id'] = ['gt', $data];
- }
- $col = 'website';
- $order = 'website_id asc';
- $fun = 'mac_url_website_detail';
- $res = model('Website')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
- break;
- case 12:
- $where['manga_status'] = ['eq',1];
- if($ac2=='today'){
- $where['manga_'.$col_time] = ['gt',$today];
- }
- if(!empty($ids)){
- $where['manga_id'] = ['in',$ids];
- }
- elseif(!empty($data)){
- $where['manga_id'] = ['gt', $data];
- }
- $col = 'manga';
- $order = 'manga_id asc';
- $fun = 'mac_url_manga_detail';
- $res = model('Manga')->listData($where,$order,$this->_param['page'],$this->_param['limit']);
- break;
- }
- if(empty($res['list'])){
- mac_echo(lang('admin/urlsend/no_data'));
- return;
- }
- mac_echo(lang('admin/urlsend/tip',[$res['total'],$res['pagecount'],$res['page']]));
- $urls = [];
- foreach($res['list'] as $k=>$v){
- $urls[$v[$col.'_id']] = $GLOBALS['http_type'] . $GLOBALS['config']['site']['site_url'] . $fun($v);
- $this->_lastid = $v[$col.'_id'];
- mac_echo($v[$col.'_id'] . '、'. $v[$col . '_name'] . ' <a href="'.$urls[$v[$col.'_id']].'">'.$urls[$v[$col.'_id']].'</a>');
- }
- $res['urls'] = $urls;
- return $res;
- }
- public function push($pp=[])
- {
- if(!empty($pp)){
- $this->_param = $pp;
- }
- $ac = $this->_param['ac'];
- $cp = 'app\\common\\extend\\urlsend\\' . ucfirst($ac);
- if (class_exists($cp)) {
- $data = $this->data();
- $c = new $cp;
- $res = $c->submit($data);
- if($res['code']!=1){
- mac_echo($res['msg']);
- die;
- }
- if ($data['page'] >= $data['pagecount']) {
- mac_echo(lang('admin/urlsend/complete'));
- if(ENTRANCE=='admin') {
- }
- }
- else {
- $this->_param['page']++;
- $url = url('urlsend/push') . '?' . http_build_query($this->_param);
- if(ENTRANCE=='admin') {
- mac_jump($url, 3);
- }
- else{
- $this->push($this->_param);
- }
- }
- }
- else{
- $this->error(lang('param_err'));
- }
- }
- }
|