<?php defined('SYSPATH') or die('No direct script access.');
class Front_Controller extends Controller{
	function __construct(){
		parent::__construct();
		define("BASEURL",Kohana::config('config.site_domain'));
		$db_cfg	=	Kohana::config('database.default');
		@define("DBFIX",$db_cfg['table_prefix']);
		@define("CHARSET",$db_cfg['character_set']);
		@define("DB_NAME",$db_cfg['connection']['database']);
		unset($db_cfg);
		//用户认证
		$auth		=	new Memberauth();
		$this->lmtpl=	new Template();
		$auth->authUser();
		//加载全局变量
		$objglobal	=	new Cfg_Model();
		$cfgList	=	$objglobal->getGlobal()->result_array(false);
		foreach ($cfgList as $tmparray) {
				@define($tmparray['global_name'],$tmparray['global_value']);
		} 
		//加载网站配置
		$baseCfg	=	$objglobal->getBaseCfg();
		foreach($baseCfg as $key=>$value){
			@define(strtoupper($key),$value);
		}
		//是否删除字符串
		@define("IS_DELETE","onclick=\"if(!confirm('确认是否删除')){return false;}\"");
		@define("VALID_NUMBER","<img src=\"".BASEURI."validn\" onclick=\"this.src='".BASEURI."validn/index/'+Math.random();\"' style='cursor:pointer;' />");
		$this->tplmodel	=	new Template_Model();
	}
	function Report($message='',$url='',$encode=false){
		if($encode){
			$message	=	Kohana::LANG("report.".$message);
			$url		=	base64_decode($url);
		}
		$this->lmtpl->message		=	$message;
		$this->lmtpl->lcationurl	=	$url;
		$this->lmtpl->render($this->tplmodel->path("member_report"));
		die();
	}
	function tplpath($value=''){
		return $this->tplmodel->path($value);
	}
}