All.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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'] = MAC_PATH_TEMPLATE;
  55. $maccms['path_ads'] = 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. $url = Request::instance()->isAjax() ? '' : 'javascript:history.back(-1);';
  89. $wait = 3;
  90. $this->assign('url',$url);
  91. $this->assign('wait',$wait);
  92. $this->assign('msg',$msg);
  93. $html = $this->label_fetch('public/jump');
  94. header("HTTP/1.1 404 Not Found");
  95. header("Status: 404 Not Found");
  96. exit($html);
  97. }
  98. protected function label_user()
  99. {
  100. if(ENTRANCE != 'index'){
  101. return;
  102. }
  103. $user_id = intval(cookie('user_id'));
  104. $user_name = cookie('user_name');
  105. $user_check = cookie('user_check');
  106. $user = ['user_id'=>0,'user_name'=>'游客','user_portrait'=>'static/images/touxiang.png','group_id'=>1,'points'=>0];
  107. $group_list = model('Group')->getCache();
  108. if(!empty($user_id) && !empty($user_name) && !empty($user_check)){
  109. $res = model('User')->checkLogin();
  110. if($res['code'] == 1){
  111. $user = $res['info'];
  112. }
  113. else{
  114. cookie('user_id','0');
  115. cookie('user_name','游客');
  116. cookie('user_check','');
  117. $user['group'] = $group_list[1];
  118. }
  119. }
  120. else{
  121. $user['group'] = $group_list[1];
  122. }
  123. $GLOBALS['user'] = $user;
  124. $this->assign('user',$user);
  125. }
  126. protected function label_comment()
  127. {
  128. $comment = config('maccms.comment');
  129. $this->assign('comment',$comment);
  130. }
  131. protected function label_type($view=0)
  132. {
  133. $param = mac_param_url();
  134. $this->assign('param',$param);
  135. $info = mac_label_type($param);
  136. $this->assign('obj',$info);
  137. if(empty($info)){
  138. return $this->error('获取分类失败,请选择其它分类!');
  139. }
  140. if($view<2) {
  141. $res = $this->check_user_popedom($info['type_id'], 1);
  142. if($res['code']>1){
  143. echo $this->error($res['msg'], mac_url('user/index') );
  144. exit;
  145. }
  146. }
  147. return $info;
  148. }
  149. protected function label_actor($total='')
  150. {
  151. $param = mac_param_url();
  152. $this->assign('param',$param);
  153. }
  154. protected function label_actor_detail($info=[],$view=0)
  155. {
  156. $param = mac_param_url();
  157. $this->assign('param',$param);
  158. if(empty($info)) {
  159. $res = mac_label_actor_detail($param);
  160. if ($res['code'] > 1) {
  161. $this->page_error($res['msg']);;
  162. }
  163. $info = $res['info'];
  164. }
  165. if(empty($info['actor_tpl'])){
  166. $info['actor_tpl'] = $info['type']['type_tpl_detail'];
  167. }
  168. if($view <2) {
  169. $popedom = $this->check_user_popedom($info['type_id'], 2,$param,'actor',$info);
  170. $this->assign('popedom',$popedom);
  171. if($popedom['code']>1){
  172. $this->assign('obj',$info);
  173. if($popedom['confirm']==1){
  174. echo $this->fetch('actor/confirm');
  175. exit;
  176. }
  177. echo $this->error($popedom['msg'], mac_url('user/index') );
  178. exit;
  179. }
  180. }
  181. $this->assign('obj',$info);
  182. $comment = config('maccms.comment');
  183. $this->assign('comment',$comment);
  184. return $info;
  185. }
  186. protected function label_role($total='')
  187. {
  188. $param = mac_param_url();
  189. $this->assign('param',$param);
  190. }
  191. protected function label_role_detail($info=[])
  192. {
  193. $param = mac_param_url();
  194. $this->assign('param',$param);
  195. if(empty($info)) {
  196. $res = mac_label_role_detail($param);
  197. if ($res['code'] > 1) {
  198. $this->page_error($res['msg']);;
  199. }
  200. $info = $res['info'];
  201. }
  202. $this->assign('obj',$info);
  203. $comment = config('maccms.comment');
  204. $this->assign('comment',$comment);
  205. return $info;
  206. }
  207. protected function label_website_detail($info=[],$view=0)
  208. {
  209. $param = mac_param_url();
  210. $this->assign('param',$param);
  211. if(empty($info)) {
  212. $res = mac_label_website_detail($param);
  213. if ($res['code'] > 1) {
  214. $this->page_error($res['msg']);;
  215. }
  216. $info = $res['info'];
  217. }
  218. if(empty($info['website_tpl'])){
  219. $info['website_tpl'] = $info['type']['type_tpl_detail'];
  220. }
  221. if($view <2) {
  222. $popedom = $this->check_user_popedom($info['type_id'], 2,$param,'website',$info);
  223. $this->assign('popedom',$popedom);
  224. if($popedom['code']>1){
  225. $this->assign('obj',$info);
  226. if($popedom['confirm']==1){
  227. echo $this->fetch('website/confirm');
  228. exit;
  229. }
  230. echo $this->error($popedom['msg'], mac_url('user/index') );
  231. exit;
  232. }
  233. }
  234. $this->assign('obj',$info);
  235. $comment = config('maccms.comment');
  236. $this->assign('comment',$comment);
  237. return $info;
  238. }
  239. protected function label_topic_index($total='')
  240. {
  241. $param = mac_param_url();
  242. $this->assign('param',$param);
  243. if($total=='') {
  244. $where = [];
  245. $where['topic_status'] = ['eq', 1];
  246. $total = model('Topic')->countData($where);
  247. }
  248. $url = mac_url_topic_index(['page'=>'PAGELINK']);
  249. $__PAGING__ = mac_page_param($total,1,$param['page'],$url);
  250. $this->assign('__PAGING__',$__PAGING__);
  251. }
  252. protected function label_topic_detail($info=[])
  253. {
  254. $param = mac_param_url();
  255. $this->assign('param',$param);
  256. if(empty($info)) {
  257. $res = mac_label_topic_detail($param);
  258. if ($res['code'] > 1) {
  259. $this->page_error($res['msg']);;
  260. }
  261. $info = $res['info'];
  262. }
  263. $this->assign('obj',$info);
  264. $comment = config('maccms.comment');
  265. $this->assign('comment',$comment);
  266. return $info;
  267. }
  268. protected function label_art_detail($info=[],$view=0)
  269. {
  270. $param = mac_param_url();
  271. $this->assign('param',$param);
  272. if(empty($info)) {
  273. $res = mac_label_art_detail($param);
  274. if ($res['code'] > 1) {
  275. $this->page_error($res['msg']);;
  276. }
  277. $info = $res['info'];
  278. }
  279. if(empty($info['art_tpl'])){
  280. $info['art_tpl'] = $info['type']['type_tpl_detail'];
  281. }
  282. if($view <2) {
  283. $popedom = $this->check_user_popedom($info['type_id'], 2,$param,'art',$info);
  284. $this->assign('popedom',$popedom);
  285. if($popedom['code']>1){
  286. $this->assign('obj',$info);
  287. if($popedom['confirm']==1){
  288. echo $this->fetch('art/confirm');
  289. exit;
  290. }
  291. echo $this->error($popedom['msg'], mac_url('user/index') );
  292. exit;
  293. }
  294. }
  295. $this->assign('obj',$info);
  296. $url = mac_url_art_detail($info,['page'=>'PAGELINK']);
  297. $__PAGING__ = mac_page_param($info['art_page_total'],1,$param['page'],$url);
  298. $this->assign('__PAGING__',$__PAGING__);
  299. $this->label_comment();
  300. return $info;
  301. }
  302. protected function label_vod_detail($info=[],$view=0)
  303. {
  304. $param = mac_param_url();
  305. $this->assign('param',$param);
  306. if(empty($info)) {
  307. $res = mac_label_vod_detail($param);
  308. if ($res['code'] > 1){
  309. $this->page_error($res['msg']);
  310. }
  311. $info = $res['info'];
  312. }
  313. if(empty($info['vod_tpl'])){
  314. $info['vod_tpl'] = $info['type']['type_tpl_detail'];
  315. }
  316. if(empty($info['vod_tpl_play'])){
  317. $info['vod_tpl_play'] = $info['type']['type_tpl_play'];
  318. }
  319. if(empty($info['vod_tpl_down'])){
  320. $info['vod_tpl_down'] = $info['type']['type_tpl_down'];
  321. }
  322. if($view <2) {
  323. $res = $this->check_user_popedom($info['type']['type_id'], 2);
  324. if($res['code']>1){
  325. echo $this->error($res['msg'], mac_url('user/index') );
  326. exit;
  327. }
  328. }
  329. $this->assign('obj',$info);
  330. $this->label_comment();
  331. return $info;
  332. }
  333. protected function label_vod_role($info=[],$view=0)
  334. {
  335. $param = mac_param_url();
  336. $this->assign('param', $param);
  337. if (empty($info)) {
  338. $res = mac_label_vod_detail($param);
  339. if ($res['code'] > 1) {
  340. $this->page_error($res['msg']);
  341. }
  342. $info = $res['info'];
  343. }
  344. $role = mac_label_vod_role(['rid'=>intval($info['vod_id'])]);
  345. if ($role['code'] > 1) {
  346. return $this->error($role['msg']);
  347. }
  348. $info['role'] = $role['list'];
  349. $this->assign('obj',$info);
  350. }
  351. protected function label_vod_play($flag='play',$info=[],$view=0,$pe=0)
  352. {
  353. $param = mac_param_url();
  354. $this->assign('param',$param);
  355. if(empty($info)) {
  356. $res = mac_label_vod_detail($param);
  357. if ($res['code'] > 1) {
  358. $this->page_error($res['msg']);
  359. }
  360. $info = $res['info'];
  361. }
  362. if(empty($info['vod_tpl'])){
  363. $info['vod_tpl'] = $info['type']['type_tpl_detail'];
  364. }
  365. if(empty($info['vod_tpl_play'])){
  366. $info['vod_tpl_play'] = $info['type']['type_tpl_play'];
  367. }
  368. if(empty($info['vod_tpl_down'])){
  369. $info['vod_tpl_down'] = $info['type']['type_tpl_down'];
  370. }
  371. $trysee = 0;
  372. $urlfun='mac_url_vod_'.$flag;
  373. $listfun = 'vod_'.$flag.'_list';
  374. if($view <2) {
  375. if ($flag == 'play') {
  376. $trysee = $GLOBALS['config']['user']['trysee'];
  377. if($info['vod_trysee'] >0){
  378. $trysee = $info['vod_trysee'];
  379. }
  380. $popedom = $this->check_user_popedom($info['type_id'], ($pe==0 ? 3 : 5),$param,$flag,$info,$trysee);
  381. }
  382. else {
  383. $popedom = $this->check_user_popedom($info['type_id'], 4,$param,$flag,$info);
  384. }
  385. $this->assign('popedom',$popedom);
  386. if($pe==0 && $popedom['code']>1 && empty($popedom["trysee"])){
  387. $info['player_info']['flag'] = $flag;
  388. $this->assign('obj',$info);
  389. if($popedom['confirm']==1){
  390. $this->assign('flag',$flag);
  391. echo $this->fetch('vod/confirm');
  392. exit;
  393. }
  394. echo $this->error($popedom['msg'], mac_url('user/index') );
  395. exit;
  396. }
  397. }
  398. $player_info=[];
  399. $player_info['flag'] = $flag;
  400. $player_info['encrypt'] = intval($GLOBALS['config']['app']['encrypt']);
  401. $player_info['trysee'] = intval($trysee);
  402. $player_info['points'] = intval($info['vod_points_'.$flag]);
  403. $player_info['link'] = $urlfun($info,['sid'=>'{sid}','nid'=>'{nid}']);
  404. $player_info['link_next'] = '';
  405. $player_info['link_pre'] = '';
  406. if($param['nid']>1){
  407. $player_info['link_pre'] = $urlfun($info,['sid'=>$param['sid'],'nid'=>$param['nid']-1]);
  408. }
  409. if($param['nid'] < $info['vod_'.$flag.'_list'][$param['sid']]['url_count']){
  410. $player_info['link_next'] = $urlfun($info,['sid'=>$param['sid'],'nid'=>$param['nid']+1]);
  411. }
  412. $player_info['url'] = (string)$info[$listfun][$param['sid']]['urls'][$param['nid']]['url'];
  413. $player_info['url_next'] = (string)$info[$listfun][$param['sid']]['urls'][$param['nid']+1]['url'];
  414. if(substr($player_info['url'],0,6) == 'upload'){
  415. $player_info['url'] = MAC_PATH . $player_info['url'];
  416. }
  417. if(substr($player_info['url_next'],0,6) == 'upload'){
  418. $player_info['url_next'] = MAC_PATH . $player_info['url_next'];
  419. }
  420. $player_info['from'] = (string)$info[$listfun][$param['sid']]['from'];
  421. if((string)$info[$listfun][$param['sid']]['urls'][$param['nid']]['from'] != $player_info['from']){
  422. $player_info['from'] = (string)$info[$listfun][$param['sid']]['urls'][$param['nid']]['from'];
  423. }
  424. $player_info['server'] = (string)$info[$listfun][$param['sid']]['server'];
  425. $player_info['note'] = (string)$info[$listfun][$param['sid']]['note'];
  426. if($GLOBALS['config']['app']['encrypt']=='1'){
  427. $player_info['url'] = mac_escape($player_info['url']);
  428. $player_info['url_next'] = mac_escape($player_info['url_next']);
  429. }
  430. elseif($GLOBALS['config']['app']['encrypt']=='2'){
  431. $player_info['url'] = base64_encode(mac_escape($player_info['url']));
  432. $player_info['url_next'] = base64_encode(mac_escape($player_info['url_next']));
  433. }
  434. $player_info['id'] = $param['id'];
  435. $player_info['sid'] = $param['sid'];
  436. $player_info['nid'] = $param['nid'];
  437. $info['player_info'] = $player_info;
  438. $this->assign('obj',$info);
  439. $pwd_key = '1-'.($flag=='play' ?'4':'5').'-'.$info['vod_id'];
  440. 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) ) {
  441. $dy_play = mac_url('index/vod/'.$flag.'er',['id'=>$info['vod_id'],'sid'=>$param['sid'],'nid'=>$param['nid']]);
  442. $this->assign('player_data','');
  443. $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>');
  444. }
  445. else {
  446. $this->assign('player_data', '<script type="text/javascript">var player_data=' . json_encode($player_info) . '</script>');
  447. $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='.$this->_tsp.'"></script>');
  448. }
  449. $this->label_comment();
  450. return $info;
  451. }
  452. }