Make.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. use think\View;
  5. class Make extends Base
  6. {
  7. var $_param;
  8. public function __construct()
  9. {
  10. header('X-Accel-Buffering: no');
  11. $this->_param = input();
  12. $GLOBALS['ismake'] = '1';
  13. if($this->_param['ac2']=='wap'){
  14. $TMP_TEMPLATEDIR = $GLOBALS['config']['site']['mob_template_dir'];
  15. $TMP_HTMLDIR = $GLOBALS['config']['site']['mob_html_dir'];
  16. $TMP_ADSDIR = $GLOBALS['config']['site']['mob_ads_dir'];
  17. $GLOBALS['MAC_ROOT_TEMPLATE'] = ROOT_PATH .'template/'.$TMP_TEMPLATEDIR.'/'. $TMP_HTMLDIR .'/';
  18. $GLOBALS['MAC_PATH_TEMPLATE'] = MAC_PATH.'template/'.$TMP_TEMPLATEDIR.'/';
  19. $GLOBALS['MAC_PATH_TPL'] = $GLOBALS['MAC_PATH_TEMPLATE']. $TMP_HTMLDIR .'/';
  20. $GLOBALS['MAC_PATH_ADS'] = $GLOBALS['MAC_PATH_TEMPLATE']. $TMP_ADSDIR .'/';
  21. config('template.view_path', 'template/' . $TMP_TEMPLATEDIR .'/' . $TMP_HTMLDIR .'/');
  22. }
  23. parent::__construct();
  24. }
  25. protected function buildHtml($htmlfile='',$htmlpath='',$templateFile='') {
  26. if(empty($htmlfile) || empty($htmlpath) || empty($templateFile)){
  27. return false;
  28. }
  29. $content = $this->label_fetch($templateFile);
  30. $htmlfile = reset_html_filename($htmlfile);
  31. $dir = dirname($htmlfile);
  32. if(!is_dir($dir)){
  33. mkdir($dir,0777,true);
  34. }
  35. if(file_put_contents($htmlfile,$content) === false) {
  36. return false;
  37. } else {
  38. return true;
  39. }
  40. }
  41. protected function echoLink($des,$url='',$color='',$wrap=1)
  42. {
  43. if(empty($url)){
  44. echo "<font color=$color>" .$des .'</font>'. ($wrap==1? '<br>':'&nbsp;');
  45. }
  46. else{
  47. echo '<a target="_blank" href="'. $url .'">'. "<font color=$color>" . $des .'</font></a>'. ($wrap==1? '<br>':'&nbsp;');
  48. }
  49. ob_flush();flush();
  50. }
  51. public function opt()
  52. {
  53. //分类列表
  54. $type_list = model('Type')->getCache('type_list');
  55. $this->assign('type_list',$type_list);
  56. $vod_type_list = [];
  57. $vod_type_ids = [];
  58. $art_type_list = [];
  59. $art_type_ids = [];
  60. foreach($type_list as $k=>$v){
  61. if($v['type_mid'] == 1){
  62. $vod_type_list[$k] = $v;
  63. }
  64. if($v['type_mid'] == 2){
  65. $art_type_list[$k] = $v;
  66. }
  67. }
  68. $vod_type_ids = array_keys($vod_type_list);
  69. $art_type_ids = array_keys($art_type_list);
  70. $this->assign('vod_type_list',$vod_type_list);
  71. $this->assign('art_type_list',$art_type_list);
  72. $this->assign('vod_type_ids',join(',',$vod_type_ids));
  73. $this->assign('art_type_ids',join(',',$art_type_ids));
  74. //当日视频分类ids
  75. $res = model('Vod')->updateToday('type');
  76. $this->assign('vod_type_ids_today',$res['data']);
  77. //当日文章分类ids
  78. $res = model('Art')->updateToday('type');
  79. $this->assign('art_type_ids_today',$res['data']);
  80. //专题列表
  81. $where = [];
  82. $where['topic_status'] = ['eq',1];
  83. $order = 'topic_id desc';
  84. $topic_list = model('Topic')->listData($where,$order,1,999);
  85. $this->assign('topic_list',$topic_list['list']);
  86. $topic_ids = join(',',array_keys($topic_list['list']));
  87. $this->assign('topic_ids',$topic_ids);
  88. //自定义页面
  89. $label_list = [];
  90. $path = $GLOBALS['MAC_ROOT_TEMPLATE'] .'label';
  91. if(is_dir($path)){
  92. $farr = glob($path.'/*');
  93. foreach($farr as $f){
  94. if(is_file($f)){
  95. $f = str_replace($path."/","",$f);
  96. $label_list[] = $f;
  97. }
  98. }
  99. unset($farr);
  100. }
  101. $this->assign('label_list',$label_list);
  102. $this->assign('label_ids',join(',',$label_list));
  103. $this->assign('title',lang('admin/make/title'));
  104. return $this->fetch('admin@make/opt');
  105. }
  106. public function make($pp=[])
  107. {
  108. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  109. if(!empty($pp)){
  110. $this->_param = $pp;
  111. }
  112. if($this->_param['ac'] == 'index'){
  113. $this->index();
  114. }
  115. elseif($this->_param['ac'] == 'map'){
  116. $this->map();
  117. }
  118. elseif($this->_param['ac'] == 'rss'){
  119. $this->rss();
  120. }
  121. elseif($this->_param['ac'] == 'type'){
  122. $this->type();
  123. }
  124. elseif($this->_param['ac'] == 'topic_index'){
  125. $this->topic_index();
  126. }
  127. elseif($this->_param['ac'] == 'topic_info'){
  128. $this->topic_info();
  129. }
  130. elseif($this->_param['ac'] == 'rss'){
  131. $this->rss();
  132. }
  133. elseif($this->_param['ac'] == 'info'){
  134. $this->info();
  135. }
  136. elseif($this->_param['ac'] == 'label'){
  137. $this->label();
  138. }
  139. }
  140. public function index()
  141. {
  142. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  143. $GLOBALS['aid'] = mac_get_aid('index');
  144. $link = 'index.html';
  145. if($this->_param['ac2']=='wap'){
  146. $link = 'wap_index.html';
  147. }
  148. $this->label_maccms();
  149. $this->buildHtml($link,'./', 'index/index');
  150. $this->echoLink($link,'/'.$link);
  151. if(ENTRANCE=='admin'){
  152. mac_jump( url('make/opt'),3 );
  153. }
  154. exit;
  155. }
  156. public function map()
  157. {
  158. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  159. $GLOBALS['aid'] = mac_get_aid('map');
  160. $this->label_maccms();
  161. $link = 'map.html';
  162. $this->buildHtml($link,'./','map/index');
  163. $this->echoLink($link,'/'.$link);
  164. if(ENTRANCE=='admin') {
  165. mac_jump(url('make/opt'), 3);
  166. }
  167. exit;
  168. }
  169. public function rss()
  170. {
  171. mac_echo('<style type="text/css">body{font-size:12px;color: #333333;line-height:21px;}span{font-weight:bold;color:#FF0000}</style>');
  172. if(!in_array($this->_param['ac2'], ['index','baidu','google','so','sogou','bing','sm'])){
  173. return $this->error(lang('param_err'));
  174. }
  175. if(empty(intval($this->_param['ps']))){
  176. $this->_param['ps'] = 1;
  177. }
  178. $GLOBALS['aid'] = mac_get_aid('rss');
  179. $this->label_maccms();
  180. for($i=1;$i<=$this->_param['ps'];$i++){
  181. $par =[];
  182. if($i>1){
  183. $par['page'] = $i;
  184. $_REQUEST['page'] = $i;
  185. }
  186. $link = mac_url('rss/'.$this->_param['ac2'],$par);
  187. $this->buildHtml($link,'./','rss/'.$this->_param['ac2']);
  188. $this->echoLink($link,$link);
  189. }
  190. if(ENTRANCE=='admin') {
  191. mac_jump(url('make/opt'), 3);
  192. }
  193. exit;
  194. }
  195. public function type()
  196. {
  197. if($this->_param['tab'] =='art'){
  198. $ids = $this->_param['arttype'];
  199. if(empty($ids) && $this->_param['ac2']=='day'){
  200. $res = model('Art')->updateToday('type');
  201. $ids = $res['data'];
  202. }
  203. $GLOBALS['mid'] = 2;
  204. $GLOBALS['aid'] = mac_get_aid('art','type');
  205. }
  206. else{
  207. $ids = $this->_param['vodtype'];
  208. if(empty($ids) && $this->_param['ac2']=='day'){
  209. $res = model('Vod')->updateToday('type');
  210. $ids = $res['data'];
  211. }
  212. $GLOBALS['mid'] = 1;
  213. $GLOBALS['aid'] = mac_get_aid('vod','type');
  214. }
  215. if($GLOBALS['config']['view'][$this->_param['tab'].'_type'] <2){
  216. mac_echo(lang('admin/make/view_model_static_err'));
  217. exit;
  218. }
  219. $num = intval($this->_param['num']);
  220. $start = intval($this->_param['start']);
  221. $page_count = intval($this->_param['page_count']);
  222. $page_size = intval($this->_param['page_size']);
  223. $data_count = intval($this->_param['data_count']);
  224. if(empty($ids)){
  225. return $this->error(lang('param_err'));
  226. }
  227. if(!is_array($ids)){
  228. $ids = explode(',',$ids);
  229. }
  230. if ($num>=count($ids)){
  231. if(empty($this->_param['jump'])){
  232. $this->echoLink(lang('admin/make/typepage_make_complete'));
  233. if(ENTRANCE=='admin') {
  234. mac_jump(url('make/opt'), 3);
  235. }
  236. exit;
  237. }
  238. else{
  239. $this->echoLink(lang('admin/make/typepage_make_complete_later_make_index'));
  240. if(ENTRANCE=='admin') {
  241. mac_jump(url('make/index', ['jump' => 1]), 3);
  242. }
  243. exit;
  244. }
  245. }
  246. if($start<1){
  247. $start=1;
  248. }
  249. $id = $ids[$num];
  250. $type_list = model('Type')->getCache('type_list');
  251. $type_info = $type_list[$id];
  252. if(empty($data_count)){
  253. $where = [];
  254. $where['type_id|type_id_1'] = ['eq',$id];
  255. if($this->_param['tab'] =='art') {
  256. $where['art_status'] = ['eq', 1];
  257. $data_count = model('Art')->countData($where);
  258. $html = mac_read_file($GLOBALS['MAC_ROOT_TEMPLATE'] . 'art/'.$type_info['type_tpl']);
  259. $labelRule = '{maccms:art(.*?)num="(.*?)"(.*?)paging="yes"([\s\S]*?)}([\s\S]*?){/maccms:art}';
  260. }
  261. else{
  262. $where['vod_status'] = ['eq', 1];
  263. $data_count = model('Vod')->countData($where);
  264. $html = mac_read_file($GLOBALS['MAC_ROOT_TEMPLATE'] . 'vod/'.$type_info['type_tpl']);
  265. $labelRule = '{maccms:vod(.*?)num="(.*?)"(.*?)paging="yes"([\s\S]*?)}([\s\S]*?){/maccms:vod}';
  266. }
  267. $labelRule = mac_buildregx($labelRule,"");
  268. preg_match_all($labelRule,$html,$arr);
  269. for($i=0;$i<count($arr[2]);$i++) {
  270. $page_size = $arr[2][$i];
  271. break;
  272. }
  273. if(empty($page_size)){
  274. $page_size = 20;
  275. $page_count=1;
  276. }
  277. else{
  278. $page_count = ceil($data_count / $page_size);
  279. }
  280. if($page_count<1){ $page_count=1; }
  281. $this->_param['data_count'] = $data_count;
  282. $this->_param['page_count'] = $page_count;
  283. $this->_param['page_size'] = $page_size;
  284. if($type_info['type_pid'] == 0){
  285. //$this->_param['page_count'] = 1;
  286. }
  287. }
  288. if($start > $page_count){
  289. $this->_param['start'] = 1;
  290. $this->_param['num']++;
  291. $this->_param['data_count'] = 0;
  292. $this->_param['page_count'] = 0;
  293. $this->_param['page_size'] = 0;
  294. $url = url('make/make') .'?'. http_build_query($this->_param);
  295. $this->echoLink('【'.$type_info['type_name'].'】'.lang('admin/make/list_make_complate_later'));
  296. if(ENTRANCE=='admin') {
  297. mac_jump($url, 3);
  298. }
  299. exit;
  300. }
  301. $sec_count = ceil($page_count / $GLOBALS['config']['app']['makesize']);
  302. $sec = ceil($start / $GLOBALS['config']['app']['makesize']);
  303. $this->echoLink(lang('admin/make/type_tip',[$type_info['type_name'],$this->_param['page_count'],$sec_count,$sec]));
  304. $this->label_maccms();
  305. $n=1;
  306. for($i=$start;$i<=$page_count;$i++){
  307. $this->_param['start'] = $i;
  308. $_REQUEST['id'] = $id;
  309. $_REQUEST['page'] = $i;
  310. $this->label_type( $type_info['type_mid']==2 ? $GLOBALS['config']['view']['art_type'] : $GLOBALS['config']['view']['vod_type'] );
  311. $link = mac_url_type($type_info,['id'=>$id,'page'=>$i]);
  312. $this->buildHtml($link,'./', mac_tpl_fetch($this->_param['tab'],$type_info['type_tpl'],'type') );
  313. $this->echoLink(''.lang('the').$i.''.lang('page'),$link);
  314. if($GLOBALS['config']['app']['makesize'] == $n){
  315. break;
  316. }
  317. $n++;
  318. }
  319. if(ENTRANCE=='api'){
  320. if ($num+1>=count($ids)) {
  321. mac_echo(lang('admin/make/type_timming_tip',[$GLOBALS['config']['app']['makesize']]));
  322. die;
  323. }
  324. else{
  325. $this->_param['start'] = 1;
  326. $this->_param['num']++;
  327. $this->_param['data_count'] = 0;
  328. $this->_param['page_count'] = 0;
  329. $this->_param['page_size'] = 0;
  330. $this->type();
  331. }
  332. }
  333. if($this->_param['start'] >= $this->_param['page_count']){
  334. $this->_param['start'] = 1;
  335. $this->_param['num']++;
  336. $this->_param['data_count'] = 0;
  337. $this->_param['page_count'] = 0;
  338. $this->_param['page_size'] = 0;
  339. $this->echoLink('【'.$type_info['type_name'].'】'.lang('admin/make/list_make_complate_later'));
  340. }
  341. elseif($this->_param['start'] < $this->_param['page_count']){
  342. $this->_param['start']++;
  343. $this->echoLink(lang('server_rest'));
  344. }
  345. $url = url('make/make') .'?'. http_build_query($this->_param);
  346. if(ENTRANCE=='admin') {
  347. mac_jump($url, 3);
  348. }
  349. }
  350. public function topic_index()
  351. {
  352. $num = intval($this->_param['num']);
  353. $start = intval($this->_param['start']);
  354. $page_count = intval($this->_param['page_count']);
  355. $data_count = intval($this->_param['data_count']);
  356. $ids = $this->_param['topic'];
  357. $GLOBALS['mid'] = 3;
  358. $GLOBALS['aid'] = mac_get_aid('topic');
  359. if($start<1){
  360. $start=1;
  361. }
  362. $GLOBALS['config']['app']['makesize'] = 1;
  363. if($GLOBALS['config']['view']['topic_index'] <2){
  364. mac_echo(lang('admin/make/view_model_static_err'));
  365. exit;
  366. }
  367. if(empty($data_count)){
  368. $where = [];
  369. $where['topic_status'] = ['eq', 1];
  370. $data_count = model('Topic')->countData($where);
  371. $html = mac_read_file($GLOBALS['MAC_ROOT_TEMPLATE'] . 'topic/index.html');
  372. $labelRule = '{maccms:topic(.*?)num="(.*?)"(.*?)paging="yes"([\s\S]*?)}([\s\S]*?){/maccms:topic}';
  373. $labelRule = mac_buildregx($labelRule,"");
  374. preg_match_all($labelRule,$html,$arr);
  375. for($i=0;$i<count($arr[2]);$i++) {
  376. $page_size = $arr[2][$i];
  377. break;
  378. }
  379. if(empty($page_size)){
  380. $page_size = 20;
  381. }
  382. $page_count = ceil($data_count / $page_size);
  383. if($page_count<1){ $page_count=1; }
  384. $this->_param['start'] = $start;
  385. $this->_param['data_count'] = $data_count;
  386. $this->_param['page_count'] = $page_count;
  387. $this->_param['page_size'] = $page_size;
  388. }
  389. if($start > $page_count){
  390. $this->echoLink(lang('admin/make/topicpage_make_complete'));
  391. if(ENTRANCE=='admin') {
  392. mac_jump(url('make/opt'), 3);
  393. }
  394. exit;
  395. }
  396. $sec_count = ceil($page_count / $GLOBALS['config']['app']['makesize']);
  397. $sec = ceil($start / $GLOBALS['config']['app']['makesize']);
  398. $this->echoLink(lang('admin/make/topic_index_tip',[$this->_param['page_count'],$sec_count,$sec]));
  399. $this->label_maccms();
  400. $n=1;
  401. for($i=$start;$i<=$page_count;$i++){
  402. $this->_param['start'] = $i;
  403. $_REQUEST['page'] = $i;
  404. $this->label_topic_index($data_count);
  405. $link = mac_url_topic_index(['page'=>$i]);
  406. $this->buildHtml($link,'./','topic/index');
  407. $this->echoLink(lang('the').''.$i.''.lang('page'),$link);
  408. if($GLOBALS['config']['app']['makesize'] == $n){
  409. break;
  410. }
  411. $n++;
  412. }
  413. if($this->_param['start'] >= $page_count){
  414. $this->echoLink(lang('admin/make/topicpage_make_complete'));
  415. if(ENTRANCE=='admin') {
  416. mac_jump(url('make/opt'), 3);
  417. }
  418. exit;
  419. }
  420. else{
  421. $this->_param['start']++;
  422. $this->echoLink(lang('server_rest'));
  423. }
  424. $url = url('make/make') .'?'. http_build_query($this->_param);
  425. if(ENTRANCE=='admin') {
  426. mac_jump($url, 3);
  427. }
  428. }
  429. public function topic_info()
  430. {
  431. $ids = $this->_param['topic'];
  432. $GLOBALS['mid'] = 3;
  433. $GLOBALS['aid'] = mac_get_aid('topic','detail');
  434. if(empty($ids)){
  435. return $this->error(lang('param_err'));
  436. }
  437. if(!is_array($ids)){
  438. $ids = explode(',',$ids);
  439. }
  440. if($GLOBALS['config']['view']['topic_detail'] <2){
  441. mac_echo(lang('admin/make/view_model_static_err'));
  442. exit;
  443. }
  444. $data_count = count($ids);
  445. $this->echoLink(lang('admin/make/topic_tip',[$data_count]));
  446. $this->label_maccms();
  447. $n=1;
  448. foreach($ids as $a){
  449. $_REQUEST['id'] = $a;
  450. $where = [];
  451. $where['topic_id'] = ['eq',$a];
  452. $where['topic_status'] = ['eq',1];
  453. $res = model('Topic')->infoData($where);
  454. if($res['code'] == 1) {
  455. $topic_info = $res['info'];
  456. $this->label_topic_detail($topic_info);
  457. $link = mac_url_topic_detail($topic_info);
  458. $this->buildHtml($link,'./', mac_tpl_fetch('topic',$topic_info['topic_tpl'],'detail') );
  459. $this->echoLink($topic_info['topic_name'],$link);
  460. $n++;
  461. }
  462. }
  463. if(!empty($ids)){
  464. Db::name('topic')->where(['topic_id'=>['in',$ids]])->update(['topic_time_make'=>time()]);
  465. }
  466. if($this->_param['ref'] ==1 && !empty($_SERVER["HTTP_REFERER"])){
  467. if(ENTRANCE=='admin'){
  468. mac_jump($_SERVER["HTTP_REFERER"],2);
  469. }
  470. die;
  471. }
  472. $this->echoLink(lang('admin/make/topic_make_complete'));
  473. if(ENTRANCE=='admin'){
  474. mac_jump( url('make/opt') ,3);
  475. }
  476. }
  477. public function info()
  478. {
  479. $where = [];
  480. $ids = $this->_param['ids'];
  481. if($this->_param['tab'] =='art'){
  482. $type_ids = $this->_param['arttype'];
  483. $order='art_time desc';
  484. $where['art_status'] = ['eq',1];
  485. if($GLOBALS['config']['view']['art_detail'] <2){
  486. mac_echo(lang('admin/make/view_model_static_err'));
  487. exit;
  488. }
  489. }
  490. else{
  491. $type_ids = $this->_param['vodtype'];
  492. $order='vod_time desc';
  493. $where['vod_status'] = ['eq',1];
  494. if($GLOBALS['config']['view']['vod_detail'] <2 && $GLOBALS['config']['view']['vod_play'] <2 && $GLOBALS['config']['view']['vod_down'] <2){
  495. mac_echo(lang('admin/make/view_model_static_err'));
  496. exit;
  497. }
  498. }
  499. $num = intval($this->_param['num']);
  500. $start = intval($this->_param['start']);
  501. $page_count = intval($this->_param['page_count']);
  502. $data_count = intval($this->_param['data_count']);
  503. if($start<1){
  504. $start=1;
  505. }
  506. if($page_count<1){
  507. $page_count=1;
  508. }
  509. $where = [];
  510. if(empty($ids) && empty($type_ids) && empty($this->_param['ac2'])){
  511. return $this->error(lang('param_err'));
  512. }
  513. $type_name ='';
  514. if(!empty($type_ids)){
  515. if(!is_array($type_ids)){
  516. $type_ids = explode(',',$type_ids);
  517. }
  518. if ($num>=count($type_ids)){
  519. if(empty($this->_param['jump'])){
  520. $this->echoLink(lang('admin/make/info_make_complete').'1');
  521. if(ENTRANCE=='admin'){
  522. mac_jump( url('make/opt') ,3);
  523. }
  524. exit;
  525. }
  526. else{
  527. $this->echoLink(lang('admin/make/info_make_complete_later_make_type'));
  528. if(ENTRANCE=='admin'){
  529. mac_jump( url('make/make',['jump'=>1,'ac'=>'type','tab'=>$this->_param['tab'], $this->_param['tab'].'type'=> join(',',$type_ids) ,'ac2'=>'day']) ,3);
  530. }
  531. exit;
  532. }
  533. }
  534. $type_id = $type_ids[$num];
  535. $type_list = model('Type')->getCache('type_list');
  536. $type_info = $type_list[$type_id];
  537. $type_name = $type_info['type_name'];
  538. $where['type_id'] = ['eq',$type_id];
  539. }
  540. elseif(!empty($ids)){
  541. $type_name =lang('select_data');
  542. if($start > $page_count){
  543. mac_echo(lang('admin/make/info_make_complete').'2');
  544. exit;
  545. }
  546. $where[$this->_param['tab'].'_id'] = ['in',$ids];
  547. }
  548. if($this->_param['ac2'] =='day'){
  549. $type_name .=lang('today_data');
  550. $where[$this->_param['tab'].'_time'] = ['gt', strtotime(date('Y-m-d'))];
  551. if ($num>=count($type_ids)){
  552. }
  553. if($start > $page_count){
  554. //$this->echoLink('内容页生成完毕3');
  555. //mac_jump( url('make/opt') ,3);
  556. //exit;
  557. }
  558. }
  559. elseif($this->_param['ac2'] =='nomake'){
  560. $type_name =lang('no_make_data');
  561. $start=1;
  562. $data_count=0;
  563. $where[$this->_param['tab'].'_time_make'] = ['exp', Db::raw(' < '. $this->_param['tab'].'_time')];
  564. if($start > $page_count){
  565. $this->echoLink(lang('admin/make/info_make_complete').'4');
  566. if(ENTRANCE=='admin'){
  567. mac_jump( url('make/opt') ,3);
  568. }
  569. exit;
  570. }
  571. }
  572. if(ENTRANCE=='api'){
  573. $GLOBALS['config']['app']['makesize'] = 999;
  574. }
  575. if(empty($data_count)){
  576. if($this->_param['tab'] =='art'){
  577. $data_count = model('Art')->countData($where);
  578. }
  579. else{
  580. $data_count = model('Vod')->countData($where);
  581. }
  582. $page_count = ceil($data_count / $GLOBALS['config']['app']['makesize']);
  583. $page_size = $GLOBALS['config']['app']['makesize'];
  584. $this->_param['data_count'] = $data_count;
  585. $this->_param['page_count'] = $page_count;
  586. $this->_param['page_size'] = $page_size;
  587. }
  588. if($start > $page_count){
  589. $this->echoLink('【'.$type_name.'】'.lang('admin/make/info_make_complete_later'));
  590. if($this->_param['ac2'] =='nomake' ){
  591. if(ENTRANCE=='admin'){
  592. mac_jump( url('make/opt') ,3);
  593. }
  594. die;
  595. }
  596. else{
  597. }
  598. $this->_param['start'] = 1;
  599. $this->_param['num']++;
  600. $this->_param['data_count'] = 0;
  601. $this->_param['page_count'] = 0;
  602. $this->_param['page_size'] = 0;
  603. $url = url('make/make') .'?'. http_build_query($this->_param);
  604. if(ENTRANCE=='admin'){
  605. mac_jump( $url ,3);
  606. }
  607. exit;
  608. }
  609. $this->echoLink(lang('admin/make/info_tip',[$type_name,$this->_param['data_count'],$this->_param['page_count'],$this->_param['page_size'],$start]));
  610. if($this->_param['tab'] =='art') {
  611. $res = model('Art')->listData($where, $order, $start, $GLOBALS['config']['app']['makesize']);
  612. }
  613. else{
  614. $res = model('Vod')->listData($where, $order, $start, $GLOBALS['config']['app']['makesize']);
  615. }
  616. $update_ids=[];
  617. foreach($res['list'] as $k=>$v){
  618. if(!empty($v['art_id'])) {
  619. $GLOBALS['type_id'] =$v['type_id'];
  620. $GLOBALS['type_pid'] = $v['type']['type_pid'];
  621. $GLOBALS['mid'] = 2;
  622. $GLOBALS['aid'] = mac_get_aid('art','detail');
  623. $this->label_maccms();
  624. $_REQUEST['id'] = $v['art_id'];
  625. echo mac_substring($v['art_name'],100) .'&nbsp;';
  626. if(!empty($v['art_content'])) {
  627. $art_page_list = mac_art_list($v['art_title'], $v['art_note'], $v['art_content']);
  628. $art_page_total = count($art_page_list);
  629. }
  630. for($i=1;$i<=$art_page_total;$i++){
  631. $v['art_page_list'] = mac_art_list($v['art_title'], $v['art_note'], $v['art_content']);
  632. $v['art_page_total'] = count($v['art_page_list']);
  633. $_REQUEST['page'] = $i;
  634. $info = $this->label_art_detail($v,$GLOBALS['config']['view']['art_detail']);
  635. $link = mac_url_art_detail($v, ['page' => $i]);
  636. $this->buildHtml($link,'./', mac_tpl_fetch('art',$info['art_tpl'],'detail') );
  637. if($i==1) {
  638. $this->echoLink('detail', $link);
  639. }
  640. }
  641. $update_ids[] = $v['art_id'];
  642. }
  643. else{
  644. $GLOBALS['type_id'] =$v['type_id'];
  645. $GLOBALS['type_pid'] = $v['type']['type_pid'];
  646. $GLOBALS['mid'] = 1;
  647. $GLOBALS['aid'] = mac_get_aid('vod','detail');
  648. $_REQUEST['id'] = $v['vod_id'];
  649. echo $v['vod_name'].'&nbsp;';;
  650. if(!empty($v['vod_play_from'])) {
  651. $v['vod_play_list'] = mac_play_list($v['vod_play_from'], $v['vod_play_url'], $v['vod_play_server'], $v['vod_play_note'],'play');
  652. $v['vod_play_total'] = count($v['vod_play_list']);
  653. }
  654. if(!empty($v['vod_down_from'])) {
  655. $v['vod_down_list'] = mac_play_list($v['vod_down_from'], $v['vod_down_url'], $v['vod_down_server'], $v['vod_down_note'],'down');
  656. $v['vod_down_total'] = count($v['vod_down_list']);
  657. }
  658. if(!empty($v['vod_plot_name'])) {
  659. $v['vod_plot_list'] = mac_plot_list($v['vod_plot_name'], $v['vod_plot_detail']);
  660. $v['vod_plot_total'] = count($v['vod_plot_list']);
  661. }
  662. if($GLOBALS['config']['view']['vod_detail'] == 2){
  663. $this->label_maccms();
  664. $info = $this->label_vod_detail($v, $GLOBALS['config']['view']['vod_detail']);
  665. $link = mac_url_vod_detail($v);
  666. $this->buildHtml($link, './', mac_tpl_fetch('vod', $info['vod_tpl'], 'detail'));
  667. $this->echoLink('detail', $link, '', 0);
  668. }
  669. $_REQUEST['id'] = $v['vod_id'];
  670. $update_ids[] = $v['vod_id'];
  671. $flag = ['play','down'];
  672. foreach($flag as $f) {
  673. $GLOBALS['aid'] = mac_get_aid('vod',$f);
  674. $this->label_maccms();
  675. //播放页 和 下载页
  676. if ($GLOBALS['config']['view']['vod_'.$f] < 2) {
  677. }
  678. else{
  679. if ($GLOBALS['config']['view']['vod_'.$f] == 2) {
  680. $_REQUEST['sid'] = 1;
  681. $_REQUEST['nid'] = 1;
  682. $info = $this->label_vod_play($f,$v,$GLOBALS['config']['view']['vod_'.$f]);
  683. $link = ($f=='play' ?mac_url_vod_play($v,['sid'=>1,'nid'=>1]) : mac_url_vod_down($v,['sid'=>1,'nid'=>1]) );
  684. $this->buildHtml($link, './', mac_tpl_fetch('vod', $info['vod_tpl_'.$f], $f) );
  685. $this->echoLink($f, $link, '', 0);
  686. }
  687. elseif ($GLOBALS['config']['view']['vod_'.$f] == 3) {
  688. for ($i = 1; $i <= $v['vod_'.$f.'_total']; $i++) {
  689. for ($j = 1; $j <= $v['vod_'.$f.'_list'][$i]['url_count']; $j++) {
  690. $_REQUEST['sid'] = $i;
  691. $_REQUEST['nid'] = $j;
  692. $info = $this->label_vod_play($f,$v,$GLOBALS['config']['view']['vod_'.$f]);
  693. $link = ($f=='play' ? mac_url_vod_play($v, ['sid' => $i, 'nid' => $j]) : mac_url_vod_down($v, ['sid' => $i, 'nid' => $j]) );
  694. $link_sp = explode('?',$link);
  695. $this->buildHtml($link_sp[0], './', mac_tpl_fetch('vod', $info['vod_tpl_'.$f], $f) );
  696. if($i==1 && $j==1) {
  697. $this->echoLink('' . $f . '-' . $i . '-' . $j, $link, '', 0);
  698. }
  699. }
  700. }
  701. }
  702. elseif ($GLOBALS['config']['view']['vod_'.$f] == 4) {
  703. $tmp_play_list = $v['vod_'.$f.'_list'];
  704. for ($i = 1; $i <= $v['vod_'.$f.'_total']; $i++) {
  705. $v['vod_'.$f.'_list'] = [];
  706. $v['vod_'.$f.'_list'][$i] = $tmp_play_list[$i];
  707. $info = $this->label_vod_play($f,$v,$GLOBALS['config']['view']['vod_'.$f]);
  708. $link = ($f=='play' ? mac_url_vod_play($v, ['sid' => $i]) : mac_url_vod_down($v, ['sid' => $i]) );
  709. $link_sp = explode('?',$link);
  710. $this->buildHtml($link_sp[0], './', mac_tpl_fetch('vod', $info['vod_tpl_'.$f], $f) );
  711. if($i==1) {
  712. $this->echoLink('' . $f . '-' . $i, $link, '', 0);
  713. }
  714. }
  715. }
  716. }
  717. }
  718. echo '<br>';
  719. }
  720. }
  721. if(!empty($update_ids)){
  722. Db::name($this->_param['tab'])->where([$this->_param['tab'].'_id'=>['in',$update_ids]])->update([$this->_param['tab'].'_time_make'=>time()]);
  723. }
  724. if($this->_param['ref'] ==1 && !empty($_SERVER["HTTP_REFERER"])){
  725. if(ENTRANCE=='admin'){
  726. mac_jump($_SERVER["HTTP_REFERER"],2);
  727. }
  728. die;
  729. }
  730. if($start > $page_count){
  731. $this->_param['start'] = 1;
  732. $this->_param['num']++;
  733. $this->_param['data_count'] = 0;
  734. $this->_param['page_count'] = 0;
  735. $this->_param['page_size'] = 0;
  736. $this->echoLink('【'.$type_name.'】'.lang('admin/make/info_make_complete_later'));
  737. if($this->_param['ac2'] !=''){
  738. //mac_jump( url('make/opt') ,3);
  739. //die;
  740. }
  741. else{
  742. }
  743. }
  744. else{
  745. $this->_param['start'] = ++$start;
  746. $this->echoLink(lang('server_rest'));
  747. }
  748. $url = url('make/make') .'?'. http_build_query($this->_param);
  749. if(ENTRANCE=='admin'){
  750. mac_jump( $url ,3);
  751. }
  752. }
  753. public function label()
  754. {
  755. $ids = $this->_param['label'];
  756. $GLOBALS['aid'] = mac_get_aid('label');
  757. if(empty($ids)){
  758. return $this->error(lang('param_err'));
  759. }
  760. if(!is_array($ids)){
  761. $ids = explode(',',$ids);
  762. }
  763. $data_count = count($ids);
  764. $this->echoLink(lang('admin/make/label_tip',[$data_count]));
  765. $this->label_maccms();
  766. $n=1;
  767. foreach($ids as $a){
  768. $fullname = explode('.',$a)[0];
  769. $file = 'label/'.$a;
  770. $tpl = 'label/'.$fullname;
  771. $this->buildHtml($file ,'./', $tpl );
  772. $this->echoLink($file,'/'. $file);
  773. $n++;
  774. }
  775. $this->echoLink(lang('admin/make/label_complete'));
  776. if(ENTRANCE=='admin'){
  777. mac_jump( url('make/opt') ,3);
  778. }
  779. }
  780. }