All.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <?php
  2. namespace app\common\controller;
  3. use think\Controller;
  4. use think\Cache;
  5. use think\Request;
  6. class All extends Controller
  7. {
  8. var $_ref;
  9. var $_cl;
  10. var $_ac;
  11. var $_tsp;
  12. var $_url;
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. $this->_ref = mac_get_refer();
  17. $this->_cl = request()->controller();
  18. $this->_ac = request()->action();
  19. $this->_tsp = date('Ymd');
  20. }
  21. protected function load_page_cache($tpl,$type='html')
  22. {
  23. if(defined('ENTRANCE') && ENTRANCE == 'index' && $GLOBALS['config']['app']['cache_page'] ==1 && $GLOBALS['config']['app']['cache_time_page'] ) {
  24. $cach_name = $_SERVER['HTTP_HOST']. '_'. MAC_MOB . '_'. $GLOBALS['config']['app']['cache_flag']. '_' .$tpl .'_'. http_build_query(mac_param_url());
  25. $res = Cache::get($cach_name);
  26. if ($res) {
  27. if($type=='json'){
  28. $res = json_encode($res);
  29. }
  30. echo $res;
  31. die;
  32. }
  33. }
  34. }
  35. protected function label_fetch($tpl,$loadcache=1,$type='html')
  36. {
  37. if($loadcache==1){
  38. $this->load_page_cache($tpl,$type);
  39. }
  40. $html = $this->fetch($tpl);
  41. if($GLOBALS['config']['app']['compress'] == 1){
  42. $html = mac_compress_html($html);
  43. }
  44. if(defined('ENTRANCE') && ENTRANCE == 'index' && $GLOBALS['config']['app']['cache_page'] ==1 && $GLOBALS['config']['app']['cache_time_page'] ){
  45. $cach_name = $_SERVER['HTTP_HOST']. '_'. MAC_MOB . '_'. $GLOBALS['config']['app']['cache_flag']. '_' . $tpl .'_'. http_build_query(mac_param_url());
  46. $res = Cache::set($cach_name,$html,$GLOBALS['config']['app']['cache_time_page']);
  47. }
  48. return $html;
  49. }
  50. protected function label_maccms()
  51. {
  52. $maccms = $GLOBALS['config']['site'];
  53. $maccms['path'] = MAC_PATH;
  54. $maccms['path_tpl'] = $GLOBALS['MAC_PATH_TEMPLATE'];
  55. $maccms['path_ads'] = $GLOBALS['MAC_PATH_ADS'];
  56. $maccms['user_status'] = $GLOBALS['config']['user']['status'];
  57. $maccms['date'] = date('Y-m-d');
  58. $maccms['search_hot'] = $GLOBALS['config']['app']['search_hot'];
  59. $maccms['art_extend_class'] = $GLOBALS['config']['app']['art_extend_class'];
  60. $maccms['vod_extend_class'] = $GLOBALS['config']['app']['vod_extend_class'];
  61. $maccms['vod_extend_state'] = $GLOBALS['config']['app']['vod_extend_state'];
  62. $maccms['vod_extend_version'] = $GLOBALS['config']['app']['vod_extend_version'];
  63. $maccms['vod_extend_area'] = $GLOBALS['config']['app']['vod_extend_area'];
  64. $maccms['vod_extend_lang'] = $GLOBALS['config']['app']['vod_extend_lang'];
  65. $maccms['vod_extend_year'] = $GLOBALS['config']['app']['vod_extend_year'];
  66. $maccms['vod_extend_weekday'] = $GLOBALS['config']['app']['vod_extend_weekday'];
  67. $maccms['actor_extend_area'] = $GLOBALS['config']['app']['actor_extend_area'];
  68. $maccms['http_type'] = $GLOBALS['http_type'];
  69. $maccms['http_url'] = $GLOBALS['http_type']. ''.$_SERVER['SERVER_NAME'].($_SERVER["SERVER_PORT"]==80 ? '' : ':'.$_SERVER["SERVER_PORT"]).$_SERVER["REQUEST_URI"];
  70. $maccms['seo'] = $GLOBALS['config']['seo'];
  71. $maccms['controller_action'] = $this->_cl .'/'.$this->_ac;
  72. if(!empty($GLOBALS['mid'])) {
  73. $maccms['mid'] = $GLOBALS['mid'];
  74. }
  75. else{
  76. $maccms['mid'] = mac_get_mid($this->_cl);
  77. }
  78. if(!empty($GLOBALS['aid'])) {
  79. $maccms['aid'] = $GLOBALS['aid'];
  80. }
  81. else{
  82. $maccms['aid'] = mac_get_aid($this->_cl,$this->_ac);
  83. }
  84. $this->assign( ['maccms'=>$maccms] );
  85. }
  86. protected function page_error($msg='')
  87. {
  88. if(empty($msg)){
  89. $msg=lang('controller/an_error_occurred');
  90. }
  91. $url = Request::instance()->isAjax() ? '' : 'javascript:history.back(-1);';
  92. $wait = 3;
  93. $this->assign('url',$url);
  94. $this->assign('wait',$wait);
  95. $this->assign('msg',$msg);
  96. $tpl = 'jump';
  97. if(!empty($GLOBALS['config']['app']['page_404'])){
  98. $tpl = $GLOBALS['config']['app']['page_404'];
  99. }
  100. $html = $this->label_fetch('public/'.$tpl);
  101. header("HTTP/1.1 404 Not Found");
  102. header("Status: 404 Not Found");
  103. exit($html);
  104. }
  105. protected function label_user()
  106. {
  107. if(ENTRANCE != 'index'){
  108. return;
  109. }
  110. $user_id = intval(cookie('user_id'));
  111. $user_name = cookie('user_name');
  112. $user_check = cookie('user_check');
  113. $user = ['user_id'=>0,'user_name'=>lang('controller/visitor'),'user_portrait'=>'static/images/touxiang.png','group_id'=>1,'points'=>0];
  114. $group_list = model('Group')->getCache();
  115. if(!empty($user_id) && !empty($user_name) && !empty($user_check)){
  116. $res = model('User')->checkLogin();
  117. if($res['code'] == 1){
  118. $user = $res['info'];
  119. }
  120. else{
  121. cookie('user_id','0');
  122. cookie('user_name',lang('controller/visitor'));
  123. cookie('user_check','');
  124. $user['group'] = $group_list[1];
  125. }
  126. }
  127. else{
  128. $user['group'] = $group_list[1];
  129. }
  130. $GLOBALS['user'] = $user;
  131. $this->assign('user',$user);
  132. }
  133. protected function label_comment()
  134. {
  135. $comment = config('maccms.comment');
  136. $this->assign('comment',$comment);
  137. }
  138. protected function label_search($param)
  139. {
  140. $param = mac_filter_words($param);
  141. $param = mac_search_len_check($param);
  142. // vod/search 各个参数下都可能出现回显关键词
  143. if(!empty($GLOBALS['config']['app']['wall_filter'])){
  144. $param = mac_escape_param($param);
  145. }
  146. $this->assign('param',$param);
  147. }
  148. protected function label_type($view=0, $type_id_specified = 0)
  149. {
  150. $param = mac_param_url();
  151. $param = mac_filter_words($param);
  152. $param = mac_search_len_check($param);
  153. $info = mac_label_type($param, $type_id_specified);
  154. if(!empty($GLOBALS['config']['app']['wall_filter'])){
  155. $param['wd'] = mac_escape_param($param['wd']);
  156. }
  157. $this->assign('param',$param);
  158. $this->assign('obj',$info);
  159. if(empty($info)){
  160. return $this->error(lang('controller/get_type_err'));
  161. }
  162. if($view<2) {
  163. $res = $this->check_user_popedom($info['type_id'], 1);
  164. if($res['code']>1){
  165. echo $this->error($res['msg'], mac_url('user/index') );
  166. exit;
  167. }
  168. }
  169. return $info;
  170. }
  171. protected function label_actor($total='')
  172. {
  173. $param = mac_param_url();
  174. $this->assign('param',$param);
  175. }
  176. protected function label_actor_detail($info=[],$view=0)
  177. {
  178. $param = mac_param_url();
  179. $this->assign('param',$param);
  180. if(empty($info)) {
  181. $res = mac_label_actor_detail($param);
  182. if ($res['code'] > 1) {
  183. $this->page_error($res['msg']);;
  184. }
  185. $info = $res['info'];
  186. }
  187. if(empty($info['actor_tpl'])){
  188. $info['actor_tpl'] = $info['type']['type_tpl_detail'];
  189. }
  190. if($view <2) {
  191. $popedom = $this->check_user_popedom($info['type_id'], 2,$param,'actor',$info);
  192. $this->assign('popedom',$popedom);
  193. if($popedom['code']>1){
  194. $this->assign('obj',$info);
  195. if($popedom['confirm']==1){
  196. echo $this->fetch('actor/confirm');
  197. exit;
  198. }
  199. echo $this->error($popedom['msg'], mac_url('user/index') );
  200. exit;
  201. }
  202. }
  203. $this->assign('obj',$info);
  204. $comment = config('maccms.comment');
  205. $this->assign('comment',$comment);
  206. return $info;
  207. }
  208. protected function label_role($total='')
  209. {
  210. $param = mac_param_url();
  211. $param = mac_filter_words($param);
  212. $param = mac_search_len_check($param);
  213. if(!empty($GLOBALS['app']['wall_filter'])){
  214. $param['wd'] = mac_escape_param($param['wd']);
  215. }
  216. $this->assign('param',$param);
  217. }
  218. protected function label_role_detail($info=[])
  219. {
  220. $param = mac_param_url();
  221. $this->assign('param',$param);
  222. if(empty($info)) {
  223. $res = mac_label_role_detail($param);
  224. if ($res['code'] > 1) {
  225. $this->page_error($res['msg']);;
  226. }
  227. $info = $res['info'];
  228. }
  229. $this->assign('obj',$info);
  230. $comment = config('maccms.comment');
  231. $this->assign('comment',$comment);
  232. return $info;
  233. }
  234. protected function label_website_detail($info=[],$view=0)
  235. {
  236. $param = mac_param_url();
  237. $this->assign('param',$param);
  238. if(empty($info)) {
  239. $res = mac_label_website_detail($param);
  240. if ($res['code'] > 1) {
  241. $this->page_error($res['msg']);;
  242. }
  243. $info = $res['info'];
  244. }
  245. if(empty($info['website_tpl'])){
  246. $info['website_tpl'] = $info['type']['type_tpl_detail'];
  247. }
  248. if($view <2) {
  249. $popedom = $this->check_user_popedom($info['type_id'], 2,$param,'website',$info);
  250. $this->assign('popedom',$popedom);
  251. if($popedom['code']>1){
  252. $this->assign('obj',$info);
  253. if($popedom['confirm']==1){
  254. echo $this->fetch('website/confirm');
  255. exit;
  256. }
  257. echo $this->error($popedom['msg'], mac_url('user/index') );
  258. exit;
  259. }
  260. }
  261. $this->assign('obj',$info);
  262. $comment = config('maccms.comment');
  263. $this->assign('comment',$comment);
  264. return $info;
  265. }
  266. protected function label_topic_index($total='')
  267. {
  268. $param = mac_param_url();
  269. $this->assign('param',$param);
  270. if($total=='') {
  271. $where = [];
  272. $where['topic_status'] = ['eq', 1];
  273. $total = model('Topic')->countData($where);
  274. }
  275. $url = mac_url_topic_index(['page'=>'PAGELINK']);
  276. $__PAGING__ = mac_page_param($total,1,$param['page'],$url);
  277. $this->assign('__PAGING__',$__PAGING__);
  278. }
  279. protected function label_topic_detail($info=[])
  280. {
  281. $param = mac_param_url();
  282. $this->assign('param',$param);
  283. if(empty($info)) {
  284. $res = mac_label_topic_detail($param);
  285. if ($res['code'] > 1) {
  286. $this->page_error($res['msg']);;
  287. }
  288. $info = $res['info'];
  289. }
  290. $this->assign('obj',$info);
  291. $comment = config('maccms.comment');
  292. $this->assign('comment',$comment);
  293. return $info;
  294. }
  295. protected function label_art_detail($info=[],$view=0)
  296. {
  297. $param = mac_param_url();
  298. $this->assign('param',$param);
  299. if(empty($info)) {
  300. $res = mac_label_art_detail($param);
  301. if ($res['code'] > 1) {
  302. $this->page_error($res['msg']);;
  303. }
  304. $info = $res['info'];
  305. }
  306. if(empty($info['art_tpl'])){
  307. $info['art_tpl'] = $info['type']['type_tpl_detail'];
  308. }
  309. if($view <2) {
  310. $popedom = $this->check_user_popedom($info['type_id'], 2,$param,'art',$info);
  311. $this->assign('popedom',$popedom);
  312. if($popedom['code']>1){
  313. $this->assign('obj',$info);
  314. if($popedom['confirm']==1){
  315. echo $this->fetch('art/confirm');
  316. exit;
  317. }
  318. echo $this->error($popedom['msg'], mac_url('user/index') );
  319. exit;
  320. }
  321. }
  322. $this->assign('obj',$info);
  323. $url = mac_url_art_detail($info,['page'=>'PAGELINK']);
  324. $__PAGING__ = mac_page_param($info['art_page_total'],1,$param['page'],$url);
  325. $this->assign('__PAGING__',$__PAGING__);
  326. $this->label_comment();
  327. return $info;
  328. }
  329. protected function label_vod_detail($info=[],$view=0)
  330. {
  331. $param = mac_param_url();
  332. $this->assign('param',$param);
  333. if(empty($info)) {
  334. $res = mac_label_vod_detail($param);
  335. if ($res['code'] > 1){
  336. $this->page_error($res['msg']);
  337. }
  338. $info = $res['info'];
  339. }
  340. if(empty($info['vod_tpl'])){
  341. $info['vod_tpl'] = $info['type']['type_tpl_detail'];
  342. }
  343. if(empty($info['vod_tpl_play'])){
  344. $info['vod_tpl_play'] = $info['type']['type_tpl_play'];
  345. }
  346. if(empty($info['vod_tpl_down'])){
  347. $info['vod_tpl_down'] = $info['type']['type_tpl_down'];
  348. }
  349. if($view <2) {
  350. $res = $this->check_user_popedom($info['type']['type_id'], 2);
  351. if($res['code']>1){
  352. echo $this->error($res['msg'], mac_url('user/index') );
  353. exit;
  354. }
  355. }
  356. $this->assign('obj',$info);
  357. $this->label_comment();
  358. return $info;
  359. }
  360. protected function label_vod_role($info=[],$view=0)
  361. {
  362. $param = mac_param_url();
  363. $this->assign('param', $param);
  364. if (empty($info)) {
  365. $res = mac_label_vod_detail($param);
  366. if ($res['code'] > 1) {
  367. $this->page_error($res['msg']);
  368. }
  369. $info = $res['info'];
  370. }
  371. $role = mac_label_vod_role(['rid'=>intval($info['vod_id'])]);
  372. if ($role['code'] > 1) {
  373. return $this->error($role['msg']);
  374. }
  375. $info['role'] = $role['list'];
  376. $this->assign('obj',$info);
  377. }
  378. protected function label_vod_play($flag='play',$info=[],$view=0,$pe=0)
  379. {
  380. $param = mac_param_url();
  381. $this->assign('param',$param);
  382. if(empty($info)) {
  383. $res = mac_label_vod_detail($param);
  384. if ($res['code'] > 1) {
  385. $this->page_error($res['msg']);
  386. }
  387. $info = $res['info'];
  388. }
  389. if(empty($info['vod_tpl'])){
  390. $info['vod_tpl'] = $info['type']['type_tpl_detail'];
  391. }
  392. if(empty($info['vod_tpl_play'])){
  393. $info['vod_tpl_play'] = $info['type']['type_tpl_play'];
  394. }
  395. if(empty($info['vod_tpl_down'])){
  396. $info['vod_tpl_down'] = $info['type']['type_tpl_down'];
  397. }
  398. $trysee = 0;
  399. $urlfun='mac_url_vod_'.$flag;
  400. $listfun = 'vod_'.$flag.'_list';
  401. if($view <2) {
  402. if ($flag == 'play') {
  403. $trysee = $GLOBALS['config']['user']['trysee'];
  404. if($info['vod_trysee'] >0){
  405. $trysee = $info['vod_trysee'];
  406. }
  407. $popedom = $this->check_user_popedom($info['type_id'], ($pe==0 ? 3 : 5),$param,$flag,$info,$trysee);
  408. }
  409. else {
  410. $popedom = $this->check_user_popedom($info['type_id'], 4,$param,$flag,$info);
  411. }
  412. $this->assign('popedom',$popedom);
  413. if($pe==0 && $popedom['code']>1 && empty($popedom["trysee"])){
  414. $info['player_info']['flag'] = $flag;
  415. $this->assign('obj',$info);
  416. if($popedom['confirm']==1){
  417. $this->assign('flag',$flag);
  418. echo $this->fetch('vod/confirm');
  419. exit;
  420. }
  421. echo $this->error($popedom['msg'], mac_url('user/index') );
  422. exit;
  423. }
  424. }
  425. $player_info=[];
  426. $player_info['flag'] = $flag;
  427. $player_info['encrypt'] = intval($GLOBALS['config']['app']['encrypt']);
  428. $player_info['trysee'] = intval($trysee);
  429. $player_info['points'] = intval($info['vod_points_'.$flag]);
  430. $player_info['link'] = $urlfun($info,['sid'=>'{sid}','nid'=>'{nid}']);
  431. $player_info['link_next'] = '';
  432. $player_info['link_pre'] = '';
  433. if($param['nid']>1){
  434. $player_info['link_pre'] = $urlfun($info,['sid'=>$param['sid'],'nid'=>$param['nid']-1]);
  435. }
  436. if($param['nid'] < $info['vod_'.$flag.'_list'][$param['sid']]['url_count']){
  437. $player_info['link_next'] = $urlfun($info,['sid'=>$param['sid'],'nid'=>$param['nid']+1]);
  438. }
  439. $player_info['url'] = (string)$info[$listfun][$param['sid']]['urls'][$param['nid']]['url'];
  440. $player_info['url_next'] = (string)$info[$listfun][$param['sid']]['urls'][$param['nid']+1]['url'];
  441. if(substr($player_info['url'],0,6) == 'upload'){
  442. $player_info['url'] = MAC_PATH . $player_info['url'];
  443. }
  444. if(substr($player_info['url_next'],0,6) == 'upload'){
  445. $player_info['url_next'] = MAC_PATH . $player_info['url_next'];
  446. }
  447. $player_info['from'] = (string)$info[$listfun][$param['sid']]['from'];
  448. if((string)$info[$listfun][$param['sid']]['urls'][$param['nid']]['from'] != $player_info['from']){
  449. $player_info['from'] = (string)$info[$listfun][$param['sid']]['urls'][$param['nid']]['from'];
  450. }
  451. $player_info['server'] = (string)$info[$listfun][$param['sid']]['server'];
  452. $player_info['note'] = (string)$info[$listfun][$param['sid']]['note'];
  453. if($GLOBALS['config']['app']['encrypt']=='1'){
  454. $player_info['url'] = mac_escape($player_info['url']);
  455. $player_info['url_next'] = mac_escape($player_info['url_next']);
  456. }
  457. elseif($GLOBALS['config']['app']['encrypt']=='2'){
  458. $player_info['url'] = base64_encode(mac_escape($player_info['url']));
  459. $player_info['url_next'] = base64_encode(mac_escape($player_info['url_next']));
  460. }
  461. $player_info['id'] = $param['id'];
  462. $player_info['sid'] = $param['sid'];
  463. $player_info['nid'] = $param['nid'];
  464. $info['player_info'] = $player_info;
  465. $this->assign('obj',$info);
  466. $pwd_key = '1-'.($flag=='play' ?'4':'5').'-'.$info['vod_id'];
  467. if( $pe==0 && $flag=='play' && ($popedom['trysee']>0 ) || ($info['vod_pwd_'.$flag]!='' && session($pwd_key)!='1') || ($info['vod_copyright']==1 && !empty($info['vod_jumpurl']) && $GLOBALS['config']['app']['copyright_status']==4) ) {
  468. $id = $info['vod_id'];
  469. if($GLOBALS['config']['rewrite']['vod_id']==2){
  470. $id = mac_alphaID($info['vod_id'],false,$GLOBALS['config']['rewrite']['encode_len'],$GLOBALS['config']['rewrite']['encode_key']);
  471. }
  472. $dy_play = mac_url('index/vod/'.$flag.'er',['id'=>$id,'sid'=>$param['sid'],'nid'=>$param['nid']]);
  473. $this->assign('player_data','');
  474. $this->assign('player_js','<div class="MacPlayer" style="z-index:99999;width:100%;height:100%;margin:0px;padding:0px;"><iframe id="player_if" name="player_if" src="'.$dy_play.'" style="z-index:9;width:100%;height:100%;" border="0" marginWidth="0" frameSpacing="0" marginHeight="0" frameBorder="0" scrolling="no" allowfullscreen="allowfullscreen" mozallowfullscreen="mozallowfullscreen" msallowfullscreen="msallowfullscreen" oallowfullscreen="oallowfullscreen" webkitallowfullscreen="webkitallowfullscreen" ></iframe></div>');
  475. }
  476. else {
  477. $this->assign('player_data', '<script type="text/javascript">var player_aaaa=' . json_encode($player_info) . '</script>');
  478. $this->assign('player_js', '<script type="text/javascript" src="' . MAC_PATH . 'static/js/playerconfig.js?t='.$this->_tsp.'"></script><script type="text/javascript" src="' . MAC_PATH . 'static/js/player.js?t=a'.$this->_tsp.'"></script>');
  479. }
  480. $this->label_comment();
  481. return $info;
  482. }
  483. }