⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moviecontroller.php

📁 a short sketch about linux syntex lines.
💻 PHP
字号:
<?php
class MovieController extends Easy_Controller_Action {
	public function Init(){
		$this->_Movie = new MovieModel();
		$this->_Category = new CategoryModel();
		$this->_Group = new GroupModel();
		$this->_View->config = $GLOBALS['config'];
		require(ROOT.'config/movie.conf.php');
		$this->_View->mconf = $mconf;
	}
	public function IndexAction(){
		$Player = new  PlayerModel();
		$Server = new ServerModel();
		$keyword = urldecode($this->_Request->getParams('keyword'));
		$this->_View->movie = $this->_Movie->Search($this->_Request->getParams());
		$this->_View->printpage = $this->_Movie->printPage;
		$this->_View->_Movie = $this->_Movie;
		$this->_View->Group = $this->_Group;
		$this->_View->GroupOption = $this->_Group->CreateOption($this->_Request->getParams('group'));
		$this->_View->CategoryOption = $this->_Category->CreateOption(0, $this->_Request->getParams('category'));
		$this->_View->AreaOption = $this->_Movie->AreaOption($this->_Request->getParams('area'));
		$this->_View->PlayerOption = $this->_Movie->PlayerOption($this->_Request->getParams('player'));
		$this->_View->ServerOption = $this->_Movie->ServerOption($this->_Request->getParams('sid'));
	}
	public function AddAction(){
		$cfg = new  Easy_Config();
		$Player = new  PlayerModel();
		$Server = new ServerModel();
		$smil = new SmilModel();
		include(ROOT."fckeditor/fckeditor.php") ;
		$sBasePath = $_SERVER['PHP_SELF'] ;
		$sBasePath = $this->config['basedir'].'fckeditor/';
		$this->_View->FCKeditor = new FCKeditor('content') ;
		$this->_View->FCKeditor->BasePath	= $sBasePath ;
		$this->_View->FCKeditor->Value		= _('暂无介绍');
		$this->_View->smil = $smil->getAll(array('locked'=>0));
		if ($this->_Request->isPost()){
			if ($this->_Movie->Add($this->_Request->getPost())){
				$this->_View->message = _('添加成功!');
				exit($this->_View->render('message'));
			}else{
				$this->_View->modify = $this->_Request->getPost();
				$this->_View->message = $this->_Movie->error;
				if (is_array($this->_View->modify['category'])){
					$this->_View->cate = $this->_Category->getAll('id in ('.implode(',', $this->_View->modify['category']).')');
				}else{
					$this->_View->cate = $this->_Category->getAll(array('id'=> $this->_View->modify['category']));
				}
				if (is_array($this->_View->modify['player'])){
					$this->_View->player = $Player->getAll("tag in ('".implode("','", $this->_View->modify['player'])."')");
				}else{
					$this->_View->player = $Player->getAll("tag='".$this->_View->modify['player']."'");
				}
				if (is_array($this->_View->modify['sid'])){
					$this->_View->sid = $Server->getList('sid in ('.implode(',', $this->_View->modify['sid']).')');
				}else{
					$this->_View->sid = $Server->getList('sid='.$this->_View->modify['sid']);
					$this->_Request->setCookie('sid', (int)$this->_View->sid);
				}
			}
		}else{
			$this->_View->modify['language'] = $this->_View->mconf['defaultlanguage'];
			$this->_View->modify['recmd']  = $this->_View->mconf['defaultrecommend'];
			$this->_View->modify['category'] = (int)$this->_View->mconf['category'];
			$this->_View->modify['look'] = (int)$this->_View->mconf['openlook'];
			$this->_View->modify['down'] = (int)$this->_View->mconf['opendown'];
			$this->_View->modify['area'] = trim($this->_View->mconf['defaultarea']);
			$this->_View->modify['lookpoint'] = (int)$this->_View->mconf['point'];
			$this->_View->modify['player'] = trim($this->_View->mconf['defaultplayer']);
			$this->_View->modify['sid'] = (int)$this->_Request->getCookie('sid');
			$this->_View->modify['serialise'] = 0;
		}
		$this->_View->CategoryOption = $this->_Category->CreateOptions(0, $this->_View->modify['category']);
		$this->_View->AreaOption = $this->_Movie->AreaOption($this->_View->modify['area']);
		$this->_View->PlayerOption = $this->_Movie->PlayerOption($this->_View->modify['player']);
		$this->_View->langCheckbox = $this->_Movie->getLanguage( $this->_View->modify['language'] );
		$this->_View->recmdCheckbox = $this->_Movie->getRecmdOption($this->_View->modify['recmd']);
		$this->_View->ServerOption = $this->_Movie->ServerOption($this->_View->modify['sid']);
		$this->_View->GroupOption = $this->_Group->CreateOption($this->_View->mconf['usergroup']);
	}
	public function setAction(){
		$filename = ROOT.'config/movie.conf.php';
		require($filename);
		$IO = new Easy_Filesystem();
		$this->_View->mconf = $mconf;
		$this->_View->CategoryOption = $this->_Category->CreateOptions(0, $mconf['category']);
		$this->_View->AreaOption = $this->_Movie->AreaOption($mconf['defaultarea']);
		$this->_View->PlayerOption = $this->_Movie->PlayerOption($mconf['defaultplayer']);
		$this->_View->langCheckbox = $this->_Movie->getLanguage($mconf['defaultlanguage'] );
		$this->_View->recmdCheckbox = $this->_Movie->getRecmdOption( $mconf['defaultrecommend'] );
		$this->_View->GroupOption = $this->_Group->CreateOption($mconf['usergroup']);
		if ($this->_Request->isPost()){
			$content =  $IO->getContent( $filename) ;
			$POST = $this->_Request->getPost();
			$POST['defaultlanguage'] = $POST['language'];
			$POST['defaultrecommend'] = $POST['recmd'];
			unset($POST['language'], $POST['recmd']);
			foreach ($POST as $key=>$value) {
				if (is_array($value)){
					$array = array();
					$array = var_export($value, true);
					$content = preg_replace('/\$mconf\[\''.$key.'\']+\s+\=+\s+(.+?);/is', '$mconf[\''.$key.'\'] = '.$array.';', $content);
				}elseif ( intval($value) ){
					$content = preg_replace('/\$mconf\[\''.$key.'\']+\s+\=+\s+(.+?);/is', '$mconf[\''.$key.'\'] = '.$value.';', $content);
				}else{
					$content = preg_replace('/\$mconf\[\''.$key.'\']+\s+\=(.+?);/is', '$mconf[\''.$key.'\'] = \''.$value.'\';', $content);
				}
			}
			$IO->wFile($filename, $content);
			$this->_View->message = _('保存成功!');
			
			exit($this->_View->render('message'));
		}
		
	}
	public function modifyAction(){
		$cfg = new  Easy_Config();
		$Player = new  PlayerModel();
		$Server = new ServerModel();
		$smil = new SmilModel();
		$this->_View->smil = $smil->getAll(array('locked'=>0));
		if ($this->_Request->getParam('do') == 'locked'){
			$this->_Movie->locked( (int)$this->_Request->getParam('id'));
			header('location:'.$_SERVER['HTTP_REFERER']);
			exit;
		}elseif ($this->_Request->isPost()){
			if ($this->_Movie->add($this->_Request->getPost(), 'modify')===false){
				$this->_View->message = $this->_Movie->error;
			}else{
				$this->_View->message = _('修改成功!');
				
			}
			exit($this->_View->render('message'));
		}
		if ((int)$this->_Request->getParam('movid')){
			$this->_View->modify = $this->_Movie->getRow((int)$this->_Request->getParam('movid'));
			$this->_View->AreaOption = $this->_Movie->AreaOption($this->_View->modify['area']);
			$this->_View->PlayerOption = $this->_Movie->PlayerOption($this->_View->modify['player']);
			$this->_View->langCheckbox = $this->_Movie->getLanguage( explode(',', $this->_View->modify['language']) );
			$this->_View->recmdCheckbox = $this->_Movie->getRecmdOption($this->_View->modify['recmd']);
			$this->_View->ServerOption = $this->_Movie->ServerOption($this->_View->modify['sid']);
			$this->_View->GroupOption = $this->_Group->CreateOption($this->_View->modify['lookgid']);
			include(ROOT."fckeditor/fckeditor.php") ;
			$sBasePath = $_SERVER['PHP_SELF'] ;
			$sBasePath = $this->config['basedir'].'fckeditor/';
			$this->_View->FCKeditor = new FCKeditor('content') ;
			$this->_View->FCKeditor->BasePath	= $sBasePath ;
			$this->_View->FCKeditor->Value		= stripslashes($this->_View->modify['content']);
			if ($this->_View->mconf['multiplecate'] == 2){
				if (count($this->_View->modify['category'])>0){
					$this->_View->cate = $this->_Category->getAll('id in ('.implode(',', $this->_View->modify['category']).')');
				}else{
					$this->_View->cate = $this->_Category->getAll(array('id'=> (int)$this->_View->modify['category']));
				}
			}else{
				if (is_array($this->_View->modify['category'])){
					$this->_View->modify['category'] = end($this->_View->modify['category']);
				}
			}
			$this->_View->CategoryOption = $this->_Category->CreateOptions(0, $this->_View->modify['category']);
			
			if ($this->_View->mconf['multipleplayer'] == 2){	//是否开启了多播放器选择
				if (is_array($this->_View->modify['player']) === false){
					$this->_View->modify['player'] = explode(",", $this->_View->modify['player']);
				}
				if (count($this->_View->modify['player'])>0){
					$this->_View->player = $Player->getAll("tag in ('".implode("','", $this->_View->modify['player'])."')");
				}else{
					$this->_View->player = $Player->getAll("tag='".$this->_View->modify['player']."'");
				}
			}
			if ($this->_View->mconf['multiplesid'] == 2){
				if (is_array($this->_View->modify['sid']) === false){
					$this->_View->modify['sid'] = explode(",", $this->_View->modify['sid']);
				}
				if (count($this->_View->modify['sid'])>0){
					$this->_View->sid = $Server->getList('sid in ('.implode(',', $this->_View->modify['sid']).')');
				}else{
					$this->_View->sid = $Server->getList('sid='.$this->_View->modify['sid']);
				}
			}
			//print_r($this->_View->modify['category']);
		}
	}
	/*
	批量操作修改
	*/
	public function  postAction(){
		$movid = $this->_Request->getPost('movid');
		if (count($movid)<1){
		$this->_View->message = _('请选择记录!');
			exit($this->_View->render('message'));
		}
		if (strtolower($license['version']) == 'free' || $_SERVER['HTTP_HOST'] == '127.0.0.1'){
			if ($this->_Request->getPost('num')>10){
				$this->_View->message = _('非商业版无法此项功能!');
				exit($this->_View->render('message'));
			}
		}
		if($this->_Request->getParam('act') == 'succeed'){
			$movid = $this->_Request->getPost('movid');
			if (count($movid)>0){
				$where = 'movid in ('.implode(',', $movid).')';
			}
			$sid = (int)$this->_Request->getPost('sid');
			$player = $this->_Request->getPost('player');
			$area = $this->_Request->getPost('area');
			$lookgid = $this->_Request->getPost('lookgid');
			$downgid = $this->_Request->getPost('downgid');
			$point = $this->_Request->getPost('point');
			$category = (int)$this->_Request->getPost('category');
			$data = null;
			if ($sid){
				$data['sid'] = $sid;
			}
			if ($player){
				$data['player'] = $player;
			}
			if ($area){
				$data['area'] = $area;
			}
			if ($lookgid != 'no'){
				$data['lookgid'] = (int)$lookgid;
			}
			if ($downgid != 'no'){
				$data['downgid'] = (int)$downgid;
			}
			if ($point){
				$data['lookpoint'] = (int)$point;
				$data['downpoint'] = (int)$point;
			}
			if ($category){
				$data['category'] = $category;
			}
			if ($data){
				$this->_Movie->update($data, $where);
				unset($data);
			}
			if ($category){
				$this->_Movie->initsCategory();
			}
			$uri = $this->_Request->getPost('uri');
			if ($uri){
				$this->_View->jumpurl = base64_decode($uri);
			}
			$this->_View->message = _('批量编辑成功!');
			exit($this->_View->render('message'));
		}
		$this->_View->movid = $this->_Request->getPost('movid');
		$this->_View->AreaOption = $this->_Movie->AreaOption(array(1));
		$this->_View->PlayerOption = $this->_Movie->PlayerOption(array(0));
		$this->_View->langCheckbox = $this->_Movie->getLanguage(array(0));
		$this->_View->recmdCheckbox = $this->_Movie->getRecmdOption(array(0));
		$this->_View->ServerOption = $this->_Movie->ServerOption(array(0));
		$this->_View->CategoryOption = $this->_Category->CreateOptions(0, 0);
		$this->_View->GroupOption = $this->_Group->CreateOption(0);
		
	}
	public function apiAction(){
		$this->_Movie->findError();
		$this->_View->movie = $this->_Movie->listError( $this->_Request->getParam('rule') );
		$this->_View->printpage = $this->_Movie->printPage;
	}
	public function lockedAction(){
		$ids = $this->_Request->getParams('movid');
		$this->_Movie->locked($ids);
		$this->_View->message = _('锁定成功!');
		exit($this->_View->render('message'));
	}
	public function unlockAction(){
		$ids = $this->_Request->getParams('movid');
		$this->_Movie->unlock($ids);
		$this->_View->message = _('解锁成功!');
		exit($this->_View->render('message'));
	}
	public function deleteAction(){
		$ids = $this->_Request->getParams('movid');
		if ( is_array($ids) === false ){
			$ids = array($ids);
		}
		foreach( $ids as $id){
			$this->_Movie->delete($id);
		}
		$this->_View->message = _('删除成功!');
		exit($this->_View->render('message'));
	}
}?>

⌨️ 快捷键说明

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