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

📄 smilmodel.php

📁 a short sketch about linux syntex lines.
💻 PHP
字号:
<?php
/*
秀影视频广告插播管理控制器
http://www.vodcms.com
*/
class SmilModel extends DBModel{
	public function Init(){
		if (!defined('SUCCEED_VODCMS')){
			exit();
		}
	}
	public function Add($POST){
		if (empty($POST['title'])){
			$this->error = _('请填写广告名称!');
			return false;
		}
		if ($_FILES['filename']['tmp_name']){
			$IO = new Easy_Filesystem();
			$POST['filename'] = $IO->setFile($_FILES['filename']);
		}
		$this->_DB->insert(VODCMS_SMIL, $POST);
		return $this->_DB->lastInsertID();
	}
	public function modify($POST){
		if (empty($POST['title'])){
			$this->error = _('请填写广告名称!');
			return false;
		}
		if ($POST['delfile']){
			@unlink(ROOT.strrev(base64_decode($POST['delfile'])));
			$POST['filename'] = '';
		}
		unset($POST['delfile']);
		if ($_FILES['filename']['tmp_name']){
			$IO = new Easy_Filesystem();
			$POST['filename'] = $IO->setFile($_FILES['filename']);
		}
		$id = $POST['id'];
		unset($POST['id']);
		systemlog::set('编辑了编号为'.$id.'的视频插播记录');
		return $this->_DB->update(VODCMS_SMIL, $POST, array('id'=> $id));
	}
	public function getAll($where = null){
		$select = $this->_DB->select();
		$select->from(VODCMS_SMIL);
		$select->where($where);
		$select->order('id DESC');
		$sql = $select->toString();
		$total = $this->_DB->getCount($sql);
		$this->_Page->set($total);
		$this->printPage = $this->_Page->PrintPage();
		return $this->_DB->fetAll($sql.$this->_Page->limit());
	}
	public function getRow($where = null){
		$select = $this->_DB->select();
		$select->from(VODCMS_SMIL);
		$select->where($where);
		$sql = $select->toString();
		return $this->_DB->fetrow($sql);
	}
	/*设置视频广告插播的状态*/
	public function locked($id){
		if ($id){
			$this->_DB->update(VODCMS_SMIL, 'locked = NOT(locked)', 'id='.(int)$id);
			return true;
		}else{
			$this->error = _('请传入需要隐藏或者启用记录的编号');
			return false;
		}
	}
	/*删除记录*/
	public function delete($id){
		if ($id){
			$row = $this->getRow(array('id'=>$id));
			if ($row['filename']){
				$IO = new  Easy_Filesystem();
				$IO->delete(ROOT.$row['filename']);
			}
			systemlog::set('删除了编号为'.$id.'的视频插播记录');
			return $this->_DB->Delete(VODCMS_SMIL, array('id'=>$id));
		}else{
			$this->error = _('请传入需要隐藏或者启用记录的编号');
			return false;
		}
	}
	/*播放器广告播放*/
	public function getPlay($id){
		if($id){
			$config = $GLOBALS['config'];
			$row = $this->getRow(array('locked'=>0, 'id'=>$id));
			if (!$row['id']){
				return false;
			}
			switch ($row['type']){
				case 'picture':
					$contents = '<a href="'.$row['url.'].'" target="_blank"><img src="'.$config['basedir'].$row['filename'].'" width="100%" height="96%" border="0" /></a>';
				break;
				case 'video':
					$ext = strrchr($row['video'], '.');
					if (in_array($ext, array('.rmvb', '.rm')) == false){
					$contents = '<embed src="'.$row['video'].'" type="video/x-ms-wmv" width="100%" height="96%" autoStart="1" showControls="0" showstatusbar="1" />';
					}else{
						$contents = '<object id="RVOCX" classid="CLSID:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="100%" height="96%">
						<param name="SRC" value="'.$row['video'].'">
						<PARAM NAME="AUTOSTART" VALUE="-1">
						<param name="CONTROLS" value="ImageWindow">
						<param name="CONSOLE" value="cons">
						<PARAM NAME="MAINTAINASPECT" VALUE="1">
						<embed src="'.$row['video'].'" type="audio/x-pn-realaudio-plugin" MAINTAINASPECT=1 AUTOSTART=true width="550" height="400" controls="ImageWindow" console="cons">
						</embed> </object>';
					}
				break;
				case 'swf':
					$contents = '<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" 
					codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" 
					border="0" width="100%" height="100%">
								<param name="movie" value="'.$config['basedir'].$row['filename'].'">
								<param name="quality" value="High">
								<embed src="'.$config['basedir'].$row['filename'].'" pluginspage="http://www.macromedia.com/go/getflashplayer" 
								type="application/x-shockwave-flash" name="obj1" width="500" height="500"></object>';
				break;
				case 'flv':
					$contents = '<object type="application/x-shockwave-flash" width="100%" height="96%" 
									wmode="transparent data="{basedir}images/flvplayer.swf?autoStart=true&file='.$row['video'].'">
									<param name="movie" value="{basedir}images/flvplayer.swf?autoStart=true&file='.$row['video'].'" />
									<param name="wmode" value="transparent" />
								</object>';
				break;
				case 'code':
					$contents = stripslashes($row['code']);
				break;
				default:
					throw new Exception('错误的广告类型'.$row['type']);
				break;
				
			}
			$javascript = '<script language="javascript">
			function showTime(t){
				$("#showTime").val("广告剩余时间:"+t);
				if (t>1){
					setTimeout(function(){showTime(t-1)}, 1000);
					
				}
			}
			setTimeout(function(){top.location.href="'.$_SERVER['REQUEST_URI'].'&showin=true"}, '.$row['end'].'000);
			showTime('.$row['end'].');
			</script>';
			return '<div id="bill">'.$contents.'</div><div align="center" style="margin-top:0px;"><input type="submit" value="广告剩余时间" id="showTime" name="showTime" /></div>'.$javascript;
		}
	}
}
?>

⌨️ 快捷键说明

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