Make.php 33 KB

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