All.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  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. if(!empty($GLOBALS['config']['app']['wall_filter'])){
  143. $param = mac_escape_param($param);
  144. }
  145. $this->assign('param',$param);
  146. }
  147. protected function label_type($view=0)
  148. {
  149. $param = mac_param_url();
  150. $param = mac_filter_words($param);
  151. $param = mac_search_len_check($param);
  152. $info = mac_label_type($param);
  153. if(!empty($GLOBALS['config']['app']['wall_filter'])){
  154. $param = mac_escape_param($param);
  155. }
  156. $this->assign('param',$param);
  157. $this->assign('obj',$info);
  158. if(empty($info)){
  159. return $this->error(lang('controller/get_type_err'));
  160. }
  161. if($view<2) {
  162. $res = $this->check_user_popedom($info['type_id'], 1);
  163. if($res['code']>1){
  164. echo $this->error($res['msg'], mac_url('user/index') );
  165. exit;
  166. }
  167. }
  168. return $info;
  169. }
  170. protected function label_actor($total='')
  171. {
  172. $param = mac_param_url();
  173. $this->assign('param',$param);
  174. }
  175. protected function label_actor_detail($info=[],$view=0)
  176. {
  177. $param = mac_param_url();
  178. $this->assign('param',$param);
  179. if(empty($info)) {
  180. $res = mac_label_actor_detail($param);
  181. if ($res['code'] > 1) {
  182. $this->page_error($res['msg']);;
  183. }
  184. $info = $res['info'];
  185. }
  186. if(empty($info['actor_tpl'])){
  187. $info['actor_tpl'] = $info['type']['type_tpl_detail'];
  188. }
  189. if($view <2) {
  190. $popedom = $this->check_user_popedom($info['type_id'], 2,$param,'actor',$info);
  191. $this->assign('popedom',$popedom);
  192. if($popedom['code']>1){
  193. $this->assign('obj',$info);
  194. if($popedom['confirm']==1){
  195. echo $this->fetch('actor/confirm');
  196. exit;
  197. }
  198. echo $this->error($popedom['msg'], mac_url('user/index') );
  199. exit;
  200. }
  201. }
  202. $this->assign('obj',$info);
  203. $comment = config('maccms.comment');
  204. $this->assign('comment',$comment);
  205. return $info;
  206. }
  207. protected function label_role($total='')
  208. {
  209. $param = mac_param_url();
  210. $param = mac_filter_words($param);
  211. $param = mac_search_len_check($param);
  212. if(!empty($GLOBALS['app']['wall_filter'])){
  213. $param = mac_escape_param($param);
  214. }
  215. $this->assign('param',$param);
  216. }
  217. protected function label_role_detail($info=[])
  218. {
  219. $param = mac_param_url();
  220. $this->assign('param',$param);
  221. if(empty($info)) {
  222. $res = mac_label_role_detail($param);
  223. if ($res['code'] > 1) {
  224. $this->page_error($res['msg']);;
  225. }
  226. $info = $res['info'];
  227. }
  228. $this->assign('obj',$info);
  229. $comment = config('maccms.comment');
  230. $this->assign('comment',$comment);
  231. return $info;
  232. }
  233. protected function label_website_detail($info=[],$view=0)
  234. {
  235. $param = mac_param_url();
  236. $this->assign('param',$param);
  237. if(empty($info)) {
  238. $res = mac_label_website_detail($param);
  239. if ($res['code'] > 1) {
  240. $this->page_error($res['msg']);;
  241. }
  242. $info = $res['info'];
  243. }
  244. if(empty($info['website_tpl'])){
  245. $info['website_tpl'] = $info['type']['type_tpl_detail'];
  246. }
  247. if($view <2) {
  248. $popedom = $this->check_user_popedom($info['type_id'], 2,$param,'website',$info);
  249. $this->assign('popedom',$popedom);
  250. if($popedom['code']>1){
  251. $this->assign('obj',$info);
  252. if($popedom['confirm']==1){
  253. echo $this->fetch('website/confirm');
  254. exit;
  255. }
  256. echo $this->error($popedom['msg'], mac_url('user/index') );
  257. exit;
  258. }
  259. }
  260. $this->assign('obj',$info);
  261. $comment = config('maccms.comment');
  262. $this->assign('comment',$comment);
  263. return $info;
  264. }
  265. protected function label_topic_index($total='')
  266. {
  267. $param = mac_param_url();
  268. $this->assign('param',$param);
  269. if($total=='') {
  270. $where = [];
  271. $where['topic_status'] = ['eq', 1];
  272. $total = model('Topic')->countData($where);
  273. }
  274. $url = mac_url_topic_index(['page'=>'PAGELINK']);
  275. $__PAGING__ = mac_page_param($total,1,$param['page'],$url);
  276. $this->assign('__PAGING__',$__PAGING__);
  277. }
  278. protected function label_topic_detail($info=[])
  279. {
  280. $param = mac_param_url();
  281. $this->assign('param',$param);
  282. if(empty($info)) {
  283. $res = mac_label_topic_detail($param);
  284. if ($res['code'] > 1) {
  285. $this->page_error($res['msg']);;
  286. }
  287. $info = $res['info'];
  288. }
  289. $this->assign('obj',$info);
  290. $comment = config('maccms.comment');
  291. $this->assign('comment',$comment);
  292. return $info;
  293. }
  294. protected function label_art_detail($info=[],$view=0)
  295. {
  296. $param = mac_param_url();
  297. $this->assign('param',$param);
  298. if(empty($info)) {
  299. $res = mac_label_art_detail($param);
  300. if ($res['code'] > 1) {
  301. $this->page_error($res['msg']);;
  302. }
  303. $info = $res['info'];
  304. }
  305. if(empty($info['art_tpl'])){
  306. $info['art_tpl'] = $info['type']['type_tpl_detail'];
  307. }
  308. if($view <2) {
  309. $popedom = $this->check_user_popedom($info['type_id'], 2,$param,'art',$info);
  310. $this->assign('popedom',$popedom);
  311. if($popedom['code']>1){
  312. $this->assign('obj',$info);
  313. if($popedom['confirm']==1){
  314. echo $this->fetch('art/confirm');
  315. exit;
  316. }
  317. echo $this->error($popedom['msg'], mac_url('user/index') );
  318. exit;
  319. }
  320. }
  321. $this->assign('obj',$info);
  322. $url = mac_url_art_detail($info,['page'=>'PAGELINK']);
  323. $__PAGING__ = mac_page_param($info['art_page_total'],1,$param['page'],$url);
  324. $this->assign('__PAGING__',$__PAGING__);
  325. $this->label_comment();
  326. return $info;
  327. }
  328. protected function label_vod_detail($info=[],$view=0)
  329. {
  330. $param = mac_param_url();
  331. $this->assign('param',$param);
  332. if(empty($info)) {
  333. $res = mac_label_vod_detail($param);
  334. if ($res['code'] > 1){
  335. $this->page_error($res['msg']);
  336. }
  337. $info = $res['info'];
  338. }
  339. if(empty($info['vod_tpl'])){
  340. $info['vod_tpl'] = $info['type']['type_tpl_detail'];
  341. }
  342. if(empty($info['vod_tpl_play'])){
  343. $info['vod_tpl_play'] = $info['type']['type_tpl_play'];
  344. }
  345. if(empty($info['vod_tpl_down'])){
  346. $info['vod_tpl_down'] = $info['type']['type_tpl_down'];
  347. }
  348. if($view <2) {
  349. $res = $this->check_user_popedom($info['type']['type_id'], 2);
  350. if($res['code']>1){
  351. echo $this->error($res['msg'], mac_url('user/index') );
  352. exit;
  353. }
  354. }
  355. $this->assign('obj',$info);
  356. $this->label_comment();
  357. return $info;
  358. }
  359. protected function label_vod_role($info=[],$view=0)
  360. {
  361. $param = mac_param_url();
  362. $this->assign('param', $param);
  363. if (empty($info)) {
  364. $res = mac_label_vod_detail($param);
  365. if ($res['code'] > 1) {
  366. $this->page_error($res['msg']);
  367. }
  368. $info = $res['info'];
  369. }
  370. $role = mac_label_vod_role(['rid'=>intval($info['vod_id'])]);
  371. if ($role['code'] > 1) {
  372. return $this->error($role['msg']);
  373. }
  374. $info['role'] = $role['list'];
  375. $this->assign('obj',$info);
  376. }
  377. protected function label_vod_play($flag='play',$info=[],$view=0,$pe=0)
  378. {
  379. $param = mac_param_url();
  380. $this->assign('param',$param);
  381. if(empty($info)) {
  382. $res = mac_label_vod_detail($param);
  383. if ($res['code'] > 1) {
  384. $this->page_error($res['msg']);
  385. }
  386. $info = $res['info'];
  387. }
  388. if(empty($info['vod_tpl'])){
  389. $info['vod_tpl'] = $info['type']['type_tpl_detail'];
  390. }
  391. if(empty($info['vod_tpl_play'])){
  392. $info['vod_tpl_play'] = $info['type']['type_tpl_play'];
  393. }
  394. if(empty($info['vod_tpl_down'])){
  395. $info['vod_tpl_down'] = $info['type']['type_tpl_down'];
  396. }
  397. $trysee = 0;
  398. $urlfun='mac_url_vod_'.$flag;
  399. $listfun = 'vod_'.$flag.'_list';
  400. if($view <2) {
  401. if ($flag == 'play') {
  402. $trysee = $GLOBALS['config']['user']['trysee'];
  403. if($info['vod_trysee'] >0){
  404. $trysee = $info['vod_trysee'];
  405. }
  406. $popedom = $this->check_user_popedom($info['type_id'], ($pe==0 ? 3 : 5),$param,$flag,$info,$trysee);
  407. }
  408. else {
  409. $popedom = $this->check_user_popedom($info['type_id'], 4,$param,$flag,$info);
  410. }
  411. $this->assign('popedom',$popedom);
  412. if($pe==0 && $popedom['code']>1 && empty($popedom["trysee"])){
  413. $info['player_info']['flag'] = $flag;
  414. $this->assign('obj',$info);
  415. if($popedom['confirm']==1){
  416. $this->assign('flag',$flag);
  417. echo $this->fetch('vod/confirm');
  418. exit;
  419. }
  420. echo $this->error($popedom['msg'], mac_url('user/index') );
  421. exit;
  422. }
  423. }
  424. $player_info=[];
  425. $player_info['flag'] = $flag;
  426. $player_info['encrypt'] = intval($GLOBALS['config']['app']['encrypt']);
  427. $player_info['trysee'] = intval($trysee);
  428. $player_info['points'] = intval($info['vod_points_'.$flag]);
  429. $player_info['link'] = $urlfun($info,['sid'=>'{sid}','nid'=>'{nid}']);
  430. $player_info['link_next'] = '';
  431. $player_info['link_pre'] = '';
  432. if($param['nid']>1){
  433. $player_info['link_pre'] = $urlfun($info,['sid'=>$param['sid'],'nid'=>$param['nid']-1]);
  434. }
  435. if($param['nid'] < $info['vod_'.$flag.'_list'][$param['sid']]['url_count']){
  436. $player_info['link_next'] = $urlfun($info,['sid'=>$param['sid'],'nid'=>$param['nid']+1]);
  437. }
  438. $player_info['url'] = (string)$info[$listfun][$param['sid']]['urls'][$param['nid']]['url'];
  439. $player_info['url_next'] = (string)$info[$listfun][$param['sid']]['urls'][$param['nid']+1]['url'];
  440. if(substr($player_info['url'],0,6) == 'upload'){
  441. $player_info['url'] = MAC_PATH . $player_info['url'];
  442. }
  443. if(substr($player_info['url_next'],0,6) == 'upload'){
  444. $player_info['url_next'] = MAC_PATH . $player_info['url_next'];
  445. }
  446. $player_info['from'] = (string)$info[$listfun][$param['sid']]['from'];
  447. if((string)$info[$listfun][$param['sid']]['urls'][$param['nid']]['from'] != $player_info['from']){
  448. $player_info['from'] = (string)$info[$listfun][$param['sid']]['urls'][$param['nid']]['from'];
  449. }
  450. $player_info['server'] = (string)$info[$listfun][$param['sid']]['server'];
  451. $player_info['note'] = (string)$info[$listfun][$param['sid']]['note'];
  452. if($GLOBALS['config']['app']['encrypt']=='1'){
  453. $player_info['url'] = mac_escape($player_info['url']);
  454. $player_info['url_next'] = mac_escape($player_info['url_next']);
  455. }
  456. elseif($GLOBALS['config']['app']['encrypt']=='2'){
  457. $player_info['url'] = base64_encode(mac_escape($player_info['url']));
  458. $player_info['url_next'] = base64_encode(mac_escape($player_info['url_next']));
  459. }
  460. $player_info['id'] = $param['id'];
  461. $player_info['sid'] = $param['sid'];
  462. $player_info['nid'] = $param['nid'];
  463. $info['player_info'] = $player_info;
  464. $this->assign('obj',$info);
  465. $pwd_key = '1-'.($flag=='play' ?'4':'5').'-'.$info['vod_id'];
  466. 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) ) {
  467. $id = $info['vod_id'];
  468. if($GLOBALS['config']['rewrite']['vod_id']==2){
  469. $id = mac_alphaID($info['vod_id'],false,$GLOBALS['config']['rewrite']['encode_len'],$GLOBALS['config']['rewrite']['encode_key']);
  470. }
  471. $dy_play = mac_url('index/vod/'.$flag.'er',['id'=>$id,'sid'=>$param['sid'],'nid'=>$param['nid']]);
  472. $this->assign('player_data','');
  473. $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>');
  474. }
  475. else {
  476. $this->assign('player_data', '<script type="text/javascript">var player_aaaa=' . json_encode($player_info) . '</script>');
  477. $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>');
  478. }
  479. $this->label_comment();
  480. return $info;
  481. }
  482. }