主控制器

header("Content-type: text/html; charset=utf-8");
session_start();
class Cool{
	
	private static $db_static = null;

	function __get($a=''){
		if(!self::$db_static){
			
			include("class/db_class.php");
			include("inc/oa_config.php");
			$dbarr=array("host"=>$MYSQL_SERVER,"user"=>$MYSQL_USER,"pass"=>$MYSQL_PASS,"dbname"=>$MYSQL_DB,"charset"=>"utf8");
		
			self::$db_static = new DB($dbarr);
		}
		return $this->db=self::$db_static;
	}

	function load_class($cname,$params=''){
		
		include_once("./class/".$cname.".php");
		$this->$cname=new $cname($params);
		
		
	}
	function load_view($tmp,$data_arr=array()){
		if(is_array($data_arr))
		foreach($data_arr as $k=>$v){
			$$k=$v;
		}
		include_once("./views/".$tmp.".php");
	}

	
}




function load_controller(){

	$c = $_GET['c'];
	$m =  ($_GET['m']) ? $_GET['m'] : 'index';;
	// $c =uri(0);
	// $m = uri(1);
	
	$ph="./controllers/". $c . '.php';
	
	include_once($ph);
	$controller=new $c();
	$controller->$m();
	
}
load_controller();


function json_error($msg,$errcode=1){
	
	echo json_encode(array("errcode"=>$errcode,"errmsg"=>$msg));exit;
}

function json_array($ph){//读取json并转化array
	$vstr=file_get_contents($ph);
	return json_decode($vstr,true);
}

function uri($p){
	$uris=explode("/",explode("&",$_SERVER['QUERY_STRING'])[0]);
	return $uris[$p];

}

function msg($msg){
	
	include_once('views/msg.php');exit;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值