contentcontroller.php

来自「a short sketch about linux syntex lines.」· PHP 代码 · 共 321 行

PHP
321
字号
<?php
/*
秀影6.0前端控制器
*/
class ContentController extends Easy_Controller_Action {
	public function Init(){
		$this->_View->skin = $this->config['template'];
		$this->_View->Template = new Template();	//
		$this->_View->moviearea = $this->mconf['area'];
		$this->_View->config = $this->config;
	}
	public function indexAction(){
		$hash = 'allmovie';
		if (Easy_Cache::isCache($hash)){
			Easy_Cache::getCache($hash);
		}else{
			$this->_View->current = _('全部影片');
			$contents = $this->_View->render($this->_View->skin.'/all');
			Easy_Cache::set($hash, $contents);	//写入缓存
			echo $contents;
		}
		unset($contents);
		exit();
	}
	/*
	播放器地址显示
	*/
	public function frameurlAction(){
		header('Content-type: application/x-javascript');
		$movid = (int)$this->_Request->getParam('movid');
		$setplayer = trim($this->_Request->getParam('player'));
		$setserver = (int)$this->_Request->getParam('server');
		$this->_View->num = (int)$this->_Request->getParam('num') ? (int)$this->_Request->getParam('num') : 7;	//显示每多少列就换行
		$info = $this->_View->Template->getMovieInfo($movid);
		if ($info['lookgid'] == (int)$this->config['vip']){
			$isvip = true;
			if ($this->_Request->getCookie('usergroup') != $this->config['vip']){
				exit('document.write(\'您没有访问这个秘密通道影片的权限!\');');
			}
		}else{
			$isvip = false;
		}
		$this->_View->showurl = $this->_View->Template->getUrls($movid);	//获取影片所有地址
		$i = 0;
		$player = new PlayerModel();
		$info['player'] = str_replace(',', "','", $info['player']);
		$this->_View->movieplayer = $player->getAll("tag in ('".$info['player']."')");
		$server = new ServerModel();
		$sid = array_map('intval', explode(',', $info['sid']));	//将服务器ID全部数字格式化
		$this->_View->moviename = $info['title'];
		$this->_View->movieserver = $server->getList("locked=0 AND sid in (".implode(',', $sid).")");
		/*重新组织数据*/
		foreach($this->_View->showurl as $row){
			$i++;
			$row['file'] = '';
			if( empty($row['title']) ) {
				$row['title'] = $i;
			}
			$row['file'] = INSTALLDIR.'?mod=content&action=play&urlid='.$row['urlid'];
			if( $setplayer ) {
				$row['file'] = $row['file'].'&player='.$setplayer;
				unset($this->_View->movieplayer);
			}
			if( $setserver ) {
				$row['file'] = $row['file'].'&server='.$setserver;
				unset($this->_View->movieserver);
			}
			if( $this->config['target'] == 'openwindow' ) {
				$row['openurl'] = '<a href="javascript:play(\''.$row['file'].'\', '.$this->config['width'].', '.$this->config['height'].')">'.$row['title'].'</a>';
			}else{
				$row['openurl'] = '<a target="_blank" href="'.$row['file'].'">'.$row['title'].'</a>';
			}
			$this->_View->url[] = $row;
		}
		$contents = $this->_View->render('public/frameurl');
		$contents = str_replace("\\", "\\\\", $contents);
		$contents = str_replace(chr(34), "\\\"", $contents);
		$contents = str_replace(chr(39), "\\'", $contents);
		$contents = str_replace(chr(13), "\\n", $contents);
		$contents = str_replace(chr(10), "\\r", $contents);
		$contents = str_replace("'",  "&#39;",$contents);
		echo 'document.write(\''.$contents.'\')';
		unset($contents, $info, $this->_View->url);
		return true;
	}
	/*下载地址显示*/
	public function downurlAction(){
		header('Content-type: application/x-javascript');
		$movid = (int)$this->_Request->getParam('movid');
		$setserver = (int)$this->_Request->getParam('server');
		$this->_View->num = (int)$this->_Request->getParam('num') ? (int)$this->_Request->getParam('num') : 7;	//显示每多少列就换行
		//$info = $this->_View->Template->getRow($movid);
		$this->_View->showurl = $this->_View->Template->getUrls($movid);	//获取影片所有地址
		
		/*重新组织数据*/
		foreach($this->_View->showurl as $row){
			$i++;
			$row['file'] = '';
			if( empty($row['title']) ) {
				$row['title'] = $i;
			}
			$row['file'] = INSTALLDIR.'?mod=content&action=down&urlid='.$row['urlid'];
			if( $setserver ) {
				$row['file'] = $row['file'].'&server='.$setserver;
				unset($this->_View->movieserver);
			}
			if( $this->config['target'] == 'openwindow' ) {
				$row['openurl'] = '<a href="javascript:down(\''.$row['file'].'\', '.$this->config['width'].', '.$this->config['height'].')">'.$row['title'].'</a>';
			}else{
				$row['openurl'] = '<a target="_blank" href="'.$row['file'].'">'.$row['title'].'</a>';
			}
			$this->_View->url[] = $row;
		}
		$contents = $this->_View->render('public/downurl');
		$contents = str_replace("\\", "\\\\", $contents);
		$contents = str_replace(chr(34), "\\\"", $contents);
		$contents = str_replace(chr(39), "\\'", $contents);
		$contents = str_replace(chr(13), "\\n", $contents);
		$contents = str_replace(chr(10), "\\r", $contents);
		echo 'document.write(\''.$contents.'\')';
		return true;
	}
	/*输出播放器页面*/
	public function playAction(){
		$allurlid = array();
		$urlids = array();
		$urlid = (int)$this->_Request->getParam('urlid');
		require_once(ROOT.'application/check.class.php');	//加载验证文件
		$check = new Check();
		$info = $check->checkplayer($urlid);
		$allurlid = $this->_View->Template->getUrls($info['movid'], 'urlid');	//获取影片所有地址
		if(is_array($allurlid)) {
			foreach($allurlid as $row){
				$urlids[] = $row['urlid'];
			}
			$indexno = array_search($urlid, $urlids);	//取出当前播放序号索引
			if( $urlids[$indexno+1] > 0 ) {
				$this->_View->nexturlid = $urlids[$indexno+1];	//取出当前ID
			}
			unset($urlids, $allurlid);
		}
		if ($info==false){
			$this->_View->message = $check->errorinfo;
			exit($this->_View->render($this->_View->skin.'public/message'));
		}
		/*开始替换播放器标签*/
		if ($info['smil'] && $this->_Request->getparam('showin') != 'true' ){
			$Smil = new SmilModel();
			$smilbody = $Smil->getPlay($info['smil']);
			if ( $smilbody ){
				if ($info['tag'] == 'realplayer'){
				$file = INSTALLDIR.'?mod=content&action=smil&id='.$info['smil'].'&filename='.
					base64_encode(urlencode($info['server']['helixserver'].$info['url']));
				}elseif($this->_Request->getparam('showin') != 'true'){

					$this->_View->player =  $Smil->getPlay($info['smil']);//开始播放器广告
					$this->_View->player = str_replace('{basedir}', $this->config['basedir'], $this->_View->player);
					exit($this->_View->render('public/player'));
				}else{
					$file = $info['server']['helixserver'].$info['url'];
				}
			}else{
				$file = $info['server']['helixserver'].$info['url'];
			}
		}else{
			$file = $info['server']['helixserver'].$info['url'];
		}
		//echo $file;
		$this->_View->title = $info['alt'];
		$this->_View->tag = $info['tag'];
		$this->_View->player = '<div id="vodcmsplayer">'.$info['player'].'</div>';
		$this->_View->player = str_replace('{nexturlid}',
		$this->_View->nexturlid, $this->_View->player);
		$this->_View->player = str_replace('{url}', $info['url'], $this->_View->player);
		$this->_View->player = str_replace('{qvod}', $file, $this->_View->player);
	    $this->_View->player = str_replace('{bobo}', $info['bobo'], $this->_View->player);
		$this->_View->player = str_replace('&mid=', '&hallid=', $this->_View->player);
		$this->_View->player = str_replace('{server}', $info['server']['helixserver'], $this->_View->player);
		$this->_View->player = str_replace('{ftpserver}', $info['server']['ftpserver'], $this->_View->player);
		$this->_View->player = str_replace('{serverid}', $info['server']['sid'], $this->_View->player);
		$this->_View->player = str_replace('{username}', $info['username'], $this->_View->player);
		$this->_View->player = str_replace('{file}', $file, $this->_View->player);
		$this->_View->player = str_replace('{alt}', $info['alt'], $this->_View->player);
		$this->_View->player = str_replace('{basedir}', $this->config['basedir'], $this->_View->player);
		$this->_View->player = str_replace('{title}', $info['alt'], $this->_View->player);
		$this->_View->player = str_replace('{installdir}', INSTALLDIR, $this->_View->player);
		$this->_View->online = $info['online'];
		//$this->_View->player = str_replace('{url}', $info['url'], $this->_View->player);
		/*替换播放器标签结束输出内容*/
		unset($info);
		echo $this->_View->render('public/player');
		return true;
	}
	/*
	搜索控制输出
	*/
	public function searchAction(){
		//echo  $this->_Request->getParams('type');
		if ( $this->_Request->getParams('type') == 'title' ){
			$kwdobject = new keywordmodel();
			//echo $this->_Request->getParam('keyword');
			$kwdobject->addkeyword(urldecode($this->_Request->getParams('keyword')));
		}
		$this->_View->location = '节目搜索';
		$this->_View->class = '搜索结果';
		$this->_View->current = '搜索结果';
		$this->_View->category = '搜索关键词《'.urldecode($this->_Request->getParams('keyword')).'》结果';
		$this->_View->config['title'] = '搜索关键词《'.urldecode($this->_Request->getParams('keyword')).'》结果,'.$this->config['title'];
		$this->_View->type = $this->_Request->getParams('type');
		$this->_View->keyword = urldecode($this->_Request->getParams('keyword'));
		echo $this->_View->render($this->_View->skin.'/list');
		return true;
	}

	/*影片评论*/
	public function commentAction(){
		if ( (int)$this->config['pl'] == 0){
			exit('系统关闭了评论!');
		}
		$comment = new CommentsModel();
		$movie = new MovieModel();
		if ($this->_Request->getParam('delete') && $this->_Request->getCookie('admin')){
			$comment->delete($this->_Request->getParam('delete'));
			message(_('删除成功!'), 'history.back()');
			exit;
		}
		if ($this->_Request->getCookie('admin') && $this->_Request->getSession('id')){
			$this->_View->isadmin = true;
		}
		$this->_View->username = $this->_Request->getCookie('username');
		$this->_View->movid = (int)$this->_Request->getParam('movid');
		$row = $movie->getRow($this->_View->movid);
		$moviename = $row['title'];
		$this->_View->comments = $row['review'];
		if ($this->_Request->isPost()){

			$POST = $this->_Request->getPost();
			$POST['username'] = $this->_Request->getCookie('username') ? $this->_Request->getCookie('username') :  _('游客');
			$POST['movie'] = $moviename;
			$POST['locked'] = 0;
			$POST['userip'] = $_SERVER['REMOTE_ADDR'];
			if ($comment->Add($POST)===false){
				message($comment->error, 'history.back()');
				exit;
			}else{
				message(_('评论发布成功!'), 'location.href="'.$_SERVER['HTTP_REFERER'].'"');
				exit;
			}
		}else{
			$this->_View->comment = $comment->getAll(array('movid'=>$this->_View->movid));
			$this->_View->printpage = $comment->printPage;
		}
		exit($this->_View->render('public/comments'));
	}
	/*公告显示*/
	public function voteAction(){
		$id = (int)$this->_Request->getParam('id');
		$vote = new AfficheModel();
		$vote->setClick($id);
		$this->_View->vote = $vote->getRow(array('id'=>$id));
		exit($this->_View->render('public/vote'));
	}
	/*广告调用*/
	public function billAction(){
		$tag = $this->_Request->getParam('tag');
		if (empty($tag)===false){
			$bill = new BillModel();
			$row = $bill->getByTag($tag);
			print_r($row);
		}
		exit;
	}
	//*下载影片**/
	public function downAction(){
		$urlid = (int)$this->_Request->getParam('urlid');
		require_once(ROOT.'application/check.class.php');
		$check = new Check();
		$info = $check->checkdown($urlid);
		if ($info==false){
			$this->_View->message = $check->errorinfo;
			exit($this->_View->render($this->_View->skin.'public/message'));
		}
		$this->_View->filename = trim($info['filename']);
		$this->_View->title = $info['alt'];
		exit($this->_View->render('public/down'));
	}
	/*smil影片处理*/
	public function smilAction(){
		$id = (int)$this->_Request->getParam('id');
		$filename = urldecode(base64_decode($this->_Request->getParam('filename')));
		if ($id){
			header("Content-type: application/smil");
			$smil = new SmilModel();
			$row = $smil->getRow(array('id'=>$id));
			if ($row['type'] == 'video'){
				echo '<smil><head></head><body>';
				if ($row['position'] == 0){
					echo '<video src="'.$row['video'].'" dur="'.$row['end'].'s" />';
					echo '<video src="'.$filename.'" />';
				}elseif($row['position'] == 1){
					echo '<video src="'.$filename.'" />';
					echo '<video src="'.$row['video'].'" dur="'.$row['end'].'s" />';
				}elseif($row['position'] == 3){
					//echo '<par>';
					echo '<video id="a" src="'.$filename.'" dur="'.$row['start'].'s" />';
					echo '<video id="b" src="'.$row['video'].'" dur="'.$row['end'].'s" />';
					echo '<video id="c" src="'.$filename.'" clip-begin="'.($row['start']).'s" />';
					//echo '<video id="c" src="d'.$filename.'" begin="'.$row['start']+$row['end'].'s" />';
					//echo '</par>';
				}
				echo '</body>';
				echo '</smil>';
			}else{
				echo $filename;
			}
		}else{
			echo $filename;
		}
		exit;
	}
}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?