Make.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  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 = 'rss/'.$this->_param['ac2'];
  187. if($par['page']>1){
  188. $link .= $GLOBALS['config']['path']['page_sp'] . $par['page'];
  189. }
  190. $link .='.xml';
  191. $this->buildHtml($link,'./','rss/'.$this->_param['ac2']);
  192. $this->echoLink($link,'/'.$link);
  193. }
  194. if(ENTRANCE=='admin') {
  195. mac_jump(url('make/opt'), 3);
  196. }
  197. exit;
  198. }
  199. public function type()
  200. {
  201. if($this->_param['tab'] =='art'){
  202. $ids = $this->_param['arttype'];
  203. if(empty($ids) && $this->_param['ac2']=='day'){
  204. $res = model('Art')->updateToday('type');
  205. $ids = $res['data'];
  206. }
  207. $GLOBALS['mid'] = 2;
  208. $GLOBALS['aid'] = mac_get_aid('art','type');
  209. }
  210. else{
  211. $ids = $this->_param['vodtype'];
  212. if(empty($ids) && $this->_param['ac2']=='day'){
  213. $res = model('Vod')->updateToday('type');
  214. $ids = $res['data'];
  215. }
  216. $GLOBALS['mid'] = 1;
  217. $GLOBALS['aid'] = mac_get_aid('vod','type');
  218. }
  219. if($GLOBALS['config']['view'][$this->_param['tab'].'_type'] <2){
  220. mac_echo(lang('admin/make/view_model_static_err'));
  221. exit;
  222. }
  223. $num = intval($this->_param['num']);
  224. $start = intval($this->_param['start']);
  225. $page_count = intval($this->_param['page_count']);
  226. $page_size = intval($this->_param['page_size']);
  227. $data_count = intval($this->_param['data_count']);
  228. if(empty($ids)){
  229. return $this->error(lang('param_err'));
  230. }
  231. if(!is_array($ids)){
  232. $ids = explode(',',$ids);
  233. }
  234. if ($num>=count($ids)){
  235. if(empty($this->_param['jump'])){
  236. $this->echoLink(lang('admin/make/typepage_make_complete'));
  237. if(ENTRANCE=='admin') {
  238. mac_jump(url('make/opt'), 3);
  239. }
  240. exit;
  241. }
  242. else{
  243. $this->echoLink(lang('admin/make/typepage_make_complete_later_make_index'));
  244. if(ENTRANCE=='admin') {
  245. mac_jump(url('make/index', ['jump' => 1]), 3);
  246. }
  247. exit;
  248. }
  249. }
  250. if($start<1){
  251. $start=1;
  252. }
  253. $id = $ids[$num];
  254. $type_list = model('Type')->getCache('type_list');
  255. $type_info = $type_list[$id];
  256. if(empty($data_count)){
  257. $where = [];
  258. $where['type_id|type_id_1'] = ['eq',$id];
  259. if($this->_param['tab'] =='art') {
  260. $where['art_status'] = ['eq', 1];
  261. $data_count = model('Art')->countData($where);
  262. $html = mac_read_file($GLOBALS['MAC_ROOT_TEMPLATE'] . 'art/'.$type_info['type_tpl']);
  263. $labelRule = '{maccms:art(.*?)num="(.*?)"(.*?)paging="yes"([\s\S]*?)}([\s\S]*?){/maccms:art}';
  264. }
  265. else{
  266. $where['vod_status'] = ['eq', 1];
  267. $data_count = model('Vod')->countData($where);
  268. $html = mac_read_file($GLOBALS['MAC_ROOT_TEMPLATE'] . 'vod/'.$type_info['type_tpl']);
  269. $labelRule = '{maccms:vod(.*?)num="(.*?)"(.*?)paging="yes"([\s\S]*?)}([\s\S]*?){/maccms:vod}';
  270. }
  271. $labelRule = mac_buildregx($labelRule,"");
  272. preg_match_all($labelRule,$html,$arr);
  273. for($i=0;$i<count($arr[2]);$i++) {
  274. $page_size = $arr[2][$i];
  275. break;
  276. }
  277. if(empty($page_size)){
  278. $page_size = 20;
  279. $page_count=1;
  280. }
  281. else{
  282. $page_count = ceil($data_count / $page_size);
  283. }
  284. if($page_count<1){ $page_count=1; }
  285. $this->_param['data_count'] = $data_count;
  286. $this->_param['page_count'] = $page_count;
  287. $this->_param['page_size'] = $page_size;
  288. if($type_info['type_pid'] == 0){
  289. //$this->_param['page_count'] = 1;
  290. }
  291. }
  292. if($start > $page_count){
  293. $this->_param['start'] = 1;
  294. $this->_param['num']++;
  295. $this->_param['data_count'] = 0;
  296. $this->_param['page_count'] = 0;
  297. $this->_param['page_size'] = 0;
  298. $url = url('make/make') .'?'. http_build_query($this->_param);
  299. $this->echoLink('【'.$type_info['type_name'].'】'.lang('admin/make/list_make_complate_later'));
  300. if(ENTRANCE=='admin') {
  301. mac_jump($url, 3);
  302. }
  303. exit;
  304. }
  305. $sec_count = ceil($page_count / $GLOBALS['config']['app']['makesize']);
  306. $sec = ceil($start / $GLOBALS['config']['app']['makesize']);
  307. $this->echoLink(lang('admin/make/type_tip',[$type_info['type_name'],$this->_param['page_count'],$sec_count,$sec]));
  308. $this->label_maccms();
  309. $n=1;
  310. for($i=$start;$i<=$page_count;$i++){
  311. $this->_param['start'] = $i;
  312. $_REQUEST['id'] = $id;
  313. $_REQUEST['page'] = $i;
  314. $this->label_type( $type_info['type_mid']==2 ? $GLOBALS['config']['view']['art_type'] : $GLOBALS['config']['view']['vod_type'] );
  315. $link = mac_url_type($type_info,['id'=>$id,'page'=>$i]);
  316. $this->buildHtml($link,'./', mac_tpl_fetch($this->_param['tab'],$type_info['type_tpl'],'type') );
  317. $this->echoLink(''.lang('the').$i.''.lang('page'),$link);
  318. if($GLOBALS['config']['app']['makesize'] == $n){
  319. break;
  320. }
  321. $n++;
  322. }
  323. if(ENTRANCE=='api'){
  324. if ($num+1>=count($ids)) {
  325. mac_echo(lang('admin/make/type_timming_tip',[$GLOBALS['config']['app']['makesize']]));
  326. die;
  327. }
  328. else{
  329. $this->_param['start'] = 1;
  330. $this->_param['num']++;
  331. $this->_param['data_count'] = 0;
  332. $this->_param['page_count'] = 0;
  333. $this->_param['page_size'] = 0;
  334. $this->type();
  335. }
  336. }
  337. if($this->_param['start'] >= $this->_param['page_count']){
  338. $this->_param['start'] = 1;
  339. $this->_param['num']++;
  340. $this->_param['data_count'] = 0;
  341. $this->_param['page_count'] = 0;
  342. $this->_param['page_size'] = 0;
  343. $this->echoLink('【'.$type_info['type_name'].'】'.lang('admin/make/list_make_complate_later'));
  344. }
  345. elseif($this->_param['start'] < $this->_param['page_count']){
  346. $this->_param['start']++;
  347. $this->echoLink(lang('server_rest'));
  348. }
  349. $url = url('make/make') .'?'. http_build_query($this->_param);
  350. if(ENTRANCE=='admin') {
  351. mac_jump($url, 3);
  352. }
  353. }
  354. public function topic_index()
  355. {
  356. $num = intval($this->_param['num']);
  357. $start = intval($this->_param['start']);
  358. $page_count = intval($this->_param['page_count']);
  359. $data_count = intval($this->_param['data_count']);
  360. $ids = $this->_param['topic'];
  361. $GLOBALS['mid'] = 3;
  362. $GLOBALS['aid'] = mac_get_aid('topic');
  363. if($start<1){
  364. $start=1;
  365. }
  366. $GLOBALS['config']['app']['makesize'] = 1;
  367. if($GLOBALS['config']['view']['topic_index'] <2){
  368. mac_echo(lang('admin/make/view_model_static_err'));
  369. exit;
  370. }
  371. if(empty($data_count)){
  372. $where = [];
  373. $where['topic_status'] = ['eq', 1];
  374. $data_count = model('Topic')->countData($where);
  375. $html = mac_read_file($GLOBALS['MAC_ROOT_TEMPLATE'] . 'topic/index.html');
  376. $labelRule = '{maccms:topic(.*?)num="(.*?)"(.*?)paging="yes"([\s\S]*?)}([\s\S]*?){/maccms:topic}';
  377. $labelRule = mac_buildregx($labelRule,"");
  378. preg_match_all($labelRule,$html,$arr);
  379. for($i=0;$i<count($arr[2]);$i++) {
  380. $page_size = $arr[2][$i];
  381. break;
  382. }
  383. if(empty($page_size)){
  384. $page_size = 20;
  385. }
  386. $page_count = ceil($data_count / $page_size);
  387. if($page_count<1){ $page_count=1; }
  388. $this->_param['start'] = $start;
  389. $this->_param['data_count'] = $data_count;
  390. $this->_param['page_count'] = $page_count;
  391. $this->_param['page_size'] = $page_size;
  392. }
  393. if($start > $page_count){
  394. $this->echoLink(lang('admin/make/topicpage_make_complete'));
  395. if(ENTRANCE=='admin') {
  396. mac_jump(url('make/opt'), 3);
  397. }
  398. exit;
  399. }
  400. $sec_count = ceil($page_count / $GLOBALS['config']['app']['makesize']);
  401. $sec = ceil($start / $GLOBALS['config']['app']['makesize']);
  402. $this->echoLink(lang('admin/make/topic_index_tip',[$this->_param['page_count'],$sec_count,$sec]));
  403. $this->label_maccms();
  404. $n=1;
  405. for($i=$start;$i<=$page_count;$i++){
  406. $this->_param['start'] = $i;
  407. $_REQUEST['page'] = $i;
  408. $this->label_topic_index($data_count);
  409. $link = mac_url_topic_index(['page'=>$i]);
  410. $this->buildHtml($link,'./','topic/index');
  411. $this->echoLink(lang('the').''.$i.''.lang('page'),$link);
  412. if($GLOBALS['config']['app']['makesize'] == $n){
  413. break;
  414. }
  415. $n++;
  416. }
  417. if($this->_param['start'] >= $page_count){
  418. $this->echoLink(lang('admin/make/topicpage_make_complete'));
  419. if(ENTRANCE=='admin') {
  420. mac_jump(url('make/opt'), 3);
  421. }
  422. exit;
  423. }
  424. else{
  425. $this->_param['start']++;
  426. $this->echoLink(lang('server_rest'));
  427. }
  428. $url = url('make/make') .'?'. http_build_query($this->_param);
  429. if(ENTRANCE=='admin') {
  430. mac_jump($url, 3);
  431. }
  432. }
  433. public function topic_info()
  434. {
  435. $ids = $this->_param['topic'];
  436. $GLOBALS['mid'] = 3;
  437. $GLOBALS['aid'] = mac_get_aid('topic','detail');
  438. if(empty($ids)){
  439. return $this->error(lang('param_err'));
  440. }
  441. if(!is_array($ids)){
  442. $ids = explode(',',$ids);
  443. }
  444. if($GLOBALS['config']['view']['topic_detail'] <2){
  445. mac_echo(lang('admin/make/view_model_static_err'));
  446. exit;
  447. }
  448. $data_count = count($ids);
  449. $this->echoLink(lang('admin/make/topic_tip',[$data_count]));
  450. $this->label_maccms();
  451. $n=1;
  452. foreach($ids as $a){
  453. $_REQUEST['id'] = $a;
  454. $where = [];
  455. $where['topic_id'] = ['eq',$a];
  456. $where['topic_status'] = ['eq',1];
  457. $res = model('Topic')->infoData($where);
  458. if($res['code'] == 1) {
  459. $topic_info = $res['info'];
  460. $this->label_topic_detail($topic_info);
  461. $link = mac_url_topic_detail($topic_info);
  462. $this->buildHtml($link,'./', mac_tpl_fetch('topic',$topic_info['topic_tpl'],'detail') );
  463. $this->echoLink($topic_info['topic_name'],$link);
  464. $n++;
  465. }
  466. }
  467. if(!empty($ids)){
  468. Db::name('topic')->where(['topic_id'=>['in',$ids]])->update(['topic_time_make'=>time()]);
  469. }
  470. if($this->_param['ref'] ==1 && !empty($_SERVER["HTTP_REFERER"])){
  471. if(ENTRANCE=='admin'){
  472. mac_jump($_SERVER["HTTP_REFERER"],2);
  473. }
  474. die;
  475. }
  476. $this->echoLink(lang('admin/make/topic_make_complete'));
  477. if(ENTRANCE=='admin'){
  478. mac_jump( url('make/opt') ,3);
  479. }
  480. }
  481. public function info()
  482. {
  483. $where = [];
  484. $ids = $this->_param['ids'];
  485. if($this->_param['tab'] =='art'){
  486. $type_ids = $this->_param['arttype'];
  487. $order='art_time desc';
  488. $where['art_status'] = ['eq',1];
  489. if($GLOBALS['config']['view']['art_detail'] <2){
  490. mac_echo(lang('admin/make/view_model_static_err'));
  491. exit;
  492. }
  493. }
  494. else{
  495. $type_ids = $this->_param['vodtype'];
  496. $order='vod_time desc';
  497. $where['vod_status'] = ['eq',1];
  498. if($GLOBALS['config']['view']['vod_detail'] <2 && $GLOBALS['config']['view']['vod_play'] <2 && $GLOBALS['config']['view']['vod_down'] <2){
  499. mac_echo(lang('admin/make/view_model_static_err'));
  500. exit;
  501. }
  502. }
  503. $num = intval($this->_param['num']);
  504. $start = intval($this->_param['start']);
  505. $page_count = intval($this->_param['page_count']);
  506. $data_count = intval($this->_param['data_count']);
  507. if($start<1){
  508. $start=1;
  509. }
  510. if($page_count<1){
  511. $page_count=1;
  512. }
  513. $where = [];
  514. if(empty($ids) && empty($type_ids) && empty($this->_param['ac2'])){
  515. return $this->error(lang('param_err'));
  516. }
  517. $type_name ='';
  518. if(!empty($type_ids)){
  519. if(!is_array($type_ids)){
  520. $type_ids = explode(',',$type_ids);
  521. }
  522. if ($num>=count($type_ids)){
  523. if(empty($this->_param['jump'])){
  524. $this->echoLink(lang('admin/make/info_make_complete').'1');
  525. if(ENTRANCE=='admin'){
  526. mac_jump( url('make/opt') ,3);
  527. }
  528. exit;
  529. }
  530. else{
  531. $this->echoLink(lang('admin/make/info_make_complete_later_make_type'));
  532. if(ENTRANCE=='admin'){
  533. mac_jump( url('make/make',['jump'=>1,'ac'=>'type','tab'=>$this->_param['tab'], $this->_param['tab'].'type'=> join(',',$type_ids) ,'ac2'=>'day']) ,3);
  534. }
  535. exit;
  536. }
  537. }
  538. $type_id = $type_ids[$num];
  539. $type_list = model('Type')->getCache('type_list');
  540. $type_info = $type_list[$type_id];
  541. $type_name = $type_info['type_name'];
  542. $where['type_id'] = ['eq',$type_id];
  543. }
  544. elseif(!empty($ids)){
  545. $type_name =lang('select_data');
  546. if($start > $page_count){
  547. mac_echo(lang('admin/make/info_make_complete').'2');
  548. exit;
  549. }
  550. $where[$this->_param['tab'].'_id'] = ['in',$ids];
  551. }
  552. if($this->_param['ac2'] =='day'){
  553. $type_name .=lang('today_data');
  554. $where[$this->_param['tab'].'_time'] = ['gt', strtotime(date('Y-m-d'))];
  555. if ($num>=count($type_ids)){
  556. }
  557. if($start > $page_count){
  558. //$this->echoLink('内容页生成完毕3');
  559. //mac_jump( url('make/opt') ,3);
  560. //exit;
  561. }
  562. }
  563. elseif($this->_param['ac2'] =='nomake'){
  564. $type_name =lang('no_make_data');
  565. $start=1;
  566. $data_count=0;
  567. $where[$this->_param['tab'].'_time_make'] = ['exp', Db::raw(' < '. $this->_param['tab'].'_time')];
  568. if($start > $page_count){
  569. $this->echoLink(lang('admin/make/info_make_complete').'4');
  570. if(ENTRANCE=='admin'){
  571. mac_jump( url('make/opt') ,3);
  572. }
  573. exit;
  574. }
  575. }
  576. if(ENTRANCE=='api'){
  577. $GLOBALS['config']['app']['makesize'] = 999;
  578. }
  579. if(empty($data_count)){
  580. if($this->_param['tab'] =='art'){
  581. $data_count = model('Art')->countData($where);
  582. }
  583. else{
  584. $data_count = model('Vod')->countData($where);
  585. }
  586. $page_count = ceil($data_count / $GLOBALS['config']['app']['makesize']);
  587. $page_size = $GLOBALS['config']['app']['makesize'];
  588. $this->_param['data_count'] = $data_count;
  589. $this->_param['page_count'] = $page_count;
  590. $this->_param['page_size'] = $page_size;
  591. }
  592. if($start > $page_count){
  593. $this->echoLink('【'.$type_name.'】'.lang('admin/make/info_make_complete_later'));
  594. if($this->_param['ac2'] =='nomake' ){
  595. if(ENTRANCE=='admin'){
  596. mac_jump( url('make/opt') ,3);
  597. }
  598. die;
  599. }
  600. else{
  601. }
  602. $this->_param['start'] = 1;
  603. $this->_param['num']++;
  604. $this->_param['data_count'] = 0;
  605. $this->_param['page_count'] = 0;
  606. $this->_param['page_size'] = 0;
  607. $url = url('make/make') .'?'. http_build_query($this->_param);
  608. if(ENTRANCE=='admin'){
  609. mac_jump( $url ,3);
  610. }
  611. exit;
  612. }
  613. $this->echoLink(lang('admin/make/info_tip',[$type_name,$this->_param['data_count'],$this->_param['page_count'],$this->_param['page_size'],$start]));
  614. if($this->_param['tab'] =='art') {
  615. $res = model('Art')->listData($where, $order, $start, $GLOBALS['config']['app']['makesize']);
  616. }
  617. else{
  618. $res = model('Vod')->listData($where, $order, $start, $GLOBALS['config']['app']['makesize']);
  619. }
  620. $update_ids=[];
  621. foreach($res['list'] as $k=>$v){
  622. if(!empty($v['art_id'])) {
  623. $GLOBALS['type_id'] =$v['type_id'];
  624. $GLOBALS['type_pid'] = $v['type']['type_pid'];
  625. $GLOBALS['mid'] = 2;
  626. $GLOBALS['aid'] = mac_get_aid('art','detail');
  627. $this->label_maccms();
  628. $_REQUEST['id'] = $v['art_id'];
  629. echo mac_substring($v['art_name'],100) .'&nbsp;';
  630. if(!empty($v['art_content'])) {
  631. $art_page_list = mac_art_list($v['art_title'], $v['art_note'], $v['art_content']);
  632. $art_page_total = count($art_page_list);
  633. }
  634. for($i=1;$i<=$art_page_total;$i++){
  635. $v['art_page_list'] = mac_art_list($v['art_title'], $v['art_note'], $v['art_content']);
  636. $v['art_page_total'] = count($v['art_page_list']);
  637. $_REQUEST['page'] = $i;
  638. $info = $this->label_art_detail($v,$GLOBALS['config']['view']['art_detail']);
  639. $link = mac_url_art_detail($v, ['page' => $i]);
  640. $this->buildHtml($link,'./', mac_tpl_fetch('art',$info['art_tpl'],'detail') );
  641. if($i==1) {
  642. $this->echoLink('detail', $link);
  643. }
  644. }
  645. $update_ids[] = $v['art_id'];
  646. }
  647. else{
  648. $GLOBALS['type_id'] =$v['type_id'];
  649. $GLOBALS['type_pid'] = $v['type']['type_pid'];
  650. $GLOBALS['mid'] = 1;
  651. $GLOBALS['aid'] = mac_get_aid('vod','detail');
  652. $_REQUEST['id'] = $v['vod_id'];
  653. echo $v['vod_name'].'&nbsp;';;
  654. if(!empty($v['vod_play_from'])) {
  655. $v['vod_play_list'] = mac_play_list($v['vod_play_from'], $v['vod_play_url'], $v['vod_play_server'], $v['vod_play_note'],'play');
  656. $v['vod_play_total'] = count($v['vod_play_list']);
  657. }
  658. if(!empty($v['vod_down_from'])) {
  659. $v['vod_down_list'] = mac_play_list($v['vod_down_from'], $v['vod_down_url'], $v['vod_down_server'], $v['vod_down_note'],'down');
  660. $v['vod_down_total'] = count($v['vod_down_list']);
  661. }
  662. if(!empty($v['vod_plot_name'])) {
  663. $v['vod_plot_list'] = mac_plot_list($v['vod_plot_name'], $v['vod_plot_detail']);
  664. $v['vod_plot_total'] = count($v['vod_plot_list']);
  665. }
  666. if($GLOBALS['config']['view']['vod_detail'] == 2){
  667. $this->label_maccms();
  668. $info = $this->label_vod_detail($v, $GLOBALS['config']['view']['vod_detail']);
  669. $link = mac_url_vod_detail($v);
  670. $this->buildHtml($link, './', mac_tpl_fetch('vod', $info['vod_tpl'], 'detail'));
  671. $this->echoLink('detail', $link, '', 0);
  672. }
  673. $_REQUEST['id'] = $v['vod_id'];
  674. $update_ids[] = $v['vod_id'];
  675. $flag = ['play','down'];
  676. foreach($flag as $f) {
  677. $GLOBALS['aid'] = mac_get_aid('vod',$f);
  678. $this->label_maccms();
  679. //播放页 和 下载页
  680. if ($GLOBALS['config']['view']['vod_'.$f] < 2) {
  681. }
  682. else{
  683. if ($GLOBALS['config']['view']['vod_'.$f] == 2) {
  684. $_REQUEST['sid'] = 1;
  685. $_REQUEST['nid'] = 1;
  686. $info = $this->label_vod_play($f,$v,$GLOBALS['config']['view']['vod_'.$f]);
  687. $link = ($f=='play' ?mac_url_vod_play($v,['sid'=>1,'nid'=>1]) : mac_url_vod_down($v,['sid'=>1,'nid'=>1]) );
  688. $this->buildHtml($link, './', mac_tpl_fetch('vod', $info['vod_tpl_'.$f], $f) );
  689. $this->echoLink($f, $link, '', 0);
  690. }
  691. elseif ($GLOBALS['config']['view']['vod_'.$f] == 3) {
  692. for ($i = 1; $i <= $v['vod_'.$f.'_total']; $i++) {
  693. for ($j = 1; $j <= $v['vod_'.$f.'_list'][$i]['url_count']; $j++) {
  694. $_REQUEST['sid'] = $i;
  695. $_REQUEST['nid'] = $j;
  696. $info = $this->label_vod_play($f,$v,$GLOBALS['config']['view']['vod_'.$f]);
  697. $link = ($f=='play' ? mac_url_vod_play($v, ['sid' => $i, 'nid' => $j]) : mac_url_vod_down($v, ['sid' => $i, 'nid' => $j]) );
  698. $link_sp = explode('?',$link);
  699. $this->buildHtml($link_sp[0], './', mac_tpl_fetch('vod', $info['vod_tpl_'.$f], $f) );
  700. if($i==1 && $j==1) {
  701. $this->echoLink('' . $f . '-' . $i . '-' . $j, $link, '', 0);
  702. }
  703. }
  704. }
  705. }
  706. elseif ($GLOBALS['config']['view']['vod_'.$f] == 4) {
  707. $tmp_play_list = $v['vod_'.$f.'_list'];
  708. for ($i = 1; $i <= $v['vod_'.$f.'_total']; $i++) {
  709. $v['vod_'.$f.'_list'] = [];
  710. $v['vod_'.$f.'_list'][$i] = $tmp_play_list[$i];
  711. $info = $this->label_vod_play($f,$v,$GLOBALS['config']['view']['vod_'.$f]);
  712. $link = ($f=='play' ? mac_url_vod_play($v, ['sid' => $i]) : mac_url_vod_down($v, ['sid' => $i]) );
  713. $link_sp = explode('?',$link);
  714. $this->buildHtml($link_sp[0], './', mac_tpl_fetch('vod', $info['vod_tpl_'.$f], $f) );
  715. if($i==1) {
  716. $this->echoLink('' . $f . '-' . $i, $link, '', 0);
  717. }
  718. }
  719. }
  720. }
  721. }
  722. echo '<br>';
  723. }
  724. }
  725. if(!empty($update_ids)){
  726. Db::name($this->_param['tab'])->where([$this->_param['tab'].'_id'=>['in',$update_ids]])->update([$this->_param['tab'].'_time_make'=>time()]);
  727. }
  728. if($this->_param['ref'] ==1 && !empty($_SERVER["HTTP_REFERER"])){
  729. if(ENTRANCE=='admin'){
  730. mac_jump($_SERVER["HTTP_REFERER"],2);
  731. }
  732. die;
  733. }
  734. if($start > $page_count){
  735. $this->_param['start'] = 1;
  736. $this->_param['num']++;
  737. $this->_param['data_count'] = 0;
  738. $this->_param['page_count'] = 0;
  739. $this->_param['page_size'] = 0;
  740. $this->echoLink('【'.$type_name.'】'.lang('admin/make/info_make_complete_later'));
  741. if($this->_param['ac2'] !=''){
  742. //mac_jump( url('make/opt') ,3);
  743. //die;
  744. }
  745. else{
  746. }
  747. }
  748. else{
  749. $this->_param['start'] = ++$start;
  750. $this->echoLink(lang('server_rest'));
  751. }
  752. $url = url('make/make') .'?'. http_build_query($this->_param);
  753. if(ENTRANCE=='admin'){
  754. mac_jump( $url ,3);
  755. }
  756. }
  757. public function label()
  758. {
  759. $ids = $this->_param['label'];
  760. $GLOBALS['aid'] = mac_get_aid('label');
  761. if(empty($ids)){
  762. return $this->error(lang('param_err'));
  763. }
  764. if( count( explode("./",$ids) ) > 1){
  765. $this->error(lang('param_err').'2');
  766. return;
  767. }
  768. if(!is_array($ids)){
  769. $ids = explode(',',$ids);
  770. }
  771. $data_count = count($ids);
  772. $this->echoLink(lang('admin/make/label_tip',[$data_count]));
  773. $this->label_maccms();
  774. $n=1;
  775. foreach($ids as $a){
  776. $fullname = explode('.',$a)[0];
  777. $file = 'label/'.$a;
  778. $tpl = 'label/'.$fullname;
  779. $this->buildHtml($file ,'./', $tpl );
  780. $this->echoLink($file,'/'. $file);
  781. $n++;
  782. }
  783. $this->echoLink(lang('admin/make/label_complete'));
  784. if(ENTRANCE=='admin'){
  785. mac_jump( url('make/opt') ,3);
  786. }
  787. }
  788. }