<?php
/*
秀影EasyFramework框架
qq:24498936
msn:jdzcn_net@hotmail.com
website:http://www.vodcms.com
*/
class IndexController extends Easy_Controller_Action {
	public function Init(){
		$this->_View->setViewRoot('templates');
		$this->_View->skin = $this->config['template'];
		$this->_View->Template = new Template();	//
		$this->movcfg = new Easy_Config();
		$this->movcfg->set(ROOT.'Config/movie.ini', 'area');
		$this->_View->moviearea = $this->movcfg->data;
		$this->_View->config = $this->config;
		$this->_View->location = _('站点首页');
		if ($this->config['run'] == 1){
			exit(_('系统维护中.暂停服务...客服QQ:').$config['qq']);
		}elseif ($this->config['run'] == 0){
			exit(_('点播服务已经关闭'));
		}
	}
	public function IndexAction(){	//站点首页
		$this->_View->title = '';
		$hash = 'index';
		if ($this->config['cache']){
			if (Easy_Cache::isCache($hash)){
				Easy_Cache::getCache($hash);
			}else{
				$contents = $this->_View->render($this->_View->skin.'/index');
				Easy_Cache::set($hash, $contents);
			}
			//fwrite(fopen('sql.log', 'w'), $DB->querys);
			exit($contents);
		}else{
			$DB = $GLOBALS['DB'];
			$this->_View->querys = &$DB->querys;
			exit($this->_View->render($this->_View->skin.'/index'));
		}
		
	}
	public function FlashAction(){
		header('Content-type: application/x-javascript');
		$hash = md5($_SERVER['REQUEST_URI']).'flash';
		if (Easy_Cache::isCache($hash)){
			Easy_Cache::getCache($hash);
		}else{
			$flash = new FlashModel();
			$size = strtolower($this->_Request->getParam('size'));
			$size = explode('x', $size);
			foreach ($flash->getAll() as $row){
				$pic[] = $this->config['basedir'].$row['picture'];
				$text[] = $row['title'];
				$link[] = urlencode($row['link']);
			}
			$contents = '
			var swf_width, swf_height;
			swf_width = '.intval($size[0]).';
			swf_height = '.(int)$size[1].';
			var files = "'.implode('|', $pic).'";
			var texts = "'.implode('|', $text).'";
			var links = "'.implode('|', $link).'";
			var swf = new FlashObject("'.$this->config['basedir'].'images/flash.swf", "flash", swf_width, swf_height, 7, "#FFFFFF");
			swf.addParam("menu", "false"); 
			swf.addParam("FlashVars", "bcastr_file="+files+"&bcastr_link="+links+"&bcastr_title="+texts);
			swf.addParam("wmode", "transparent"); 
			swf.write("flashbanner");
			';
			Easy_Cache::set($hash, $contents);
			echo $contents;
			unset($contents);
		}
		exit;
	}
}