<?php
/**
 * 影片查看模块
 * @copyright reginx.com
 * $Id$
 */
class view_mod extends mogvs_mod {

	/**
     * 视频信息查看
     *
     * @param unknown_type $p1
     * @param unknown_type $p2
     */
	public function __call($p1, $p2){
		$sname = substr($p1, 0, -3);
        $sname = filter::text(str_replace(' ' , '' , $sname));
		if(preg_match('/^[0-9a-zA-Z\_\-]+$/i', $sname)){
			$vod = vod_lib::get($sname);
			if(empty($vod)){
				$this->show404(1 , '该视频不存在 !');
			}
			$cat = api_lib::getcat($vod['cat']);
			$this->assign('cat', $cat);
			$active = $urhere = array();
			if(!empty($cat['pcat'])){
				foreach($cat['pcat'] as $k => $v){
					if(empty($active)){
						$active = $k;
					}
					$urhere[$k] = $v['name'];
				}
			}else{
				$active = $cat['sname'];
			}
			$urhere[$cat['sname']] = $cat['name'];
			$urhere['cur'] =  $vod['name'];
			$views = $this->get('views' , 'C');
			if(!isset($views[$vod['id']])){
			    core::getobj('vod_tab')->exec("update vod_tab set views = views + 1 where id = {$vod['id']}");
			}
			setcookie ("views[{$vod['id']}]", REQUEST_TIME , REQUEST_TIME + 86400);
			$this->assign('active', $active);
			$this->assign('urhere', $urhere);
			$cstr = "basename = '{$vod['basename']}'";
			$this->assign('ptitle',  "《" . $vod['name'] . "》" . $this->conf['vskey'] . "_" . $cat['name']);
			$this->assign('region' , api_lib::getregion());
			$this->assign('vstatus', config_lib::$vstatus);
			$this->assign('players', config_lib::$player);
			$this->assign('vod' , $vod);
			$this->assign('skey', $vod['key']);
			$this->assign('sdesc', "《" . $vod['name'] . "》" . $cat['name'] . '的剧情介绍' . ',' . $vod['desc']);
			$this->display('vod/view.tpl.html');
		}
		$this->show404(1 , '该视频不存在 !');
	}
}
?>