<?php
if (!defined('ROOT')) exit('Can\'t Access !'); 
class controller_class{
	public $mod;
    function __construct($module,$action){ 
		$this->modules($module,$action);

    }	
	function modules($module,$action){
        $extmod = 'mod_' . $module;
		$modulepath = PATH . 'library/modules/' . $extmod . '.php';
        if(!file_exists($modulepath)) error("Module '$module' file not found！");
	        require($modulepath);		
		if(!class_exists($extmod)) error("Module '$module' class not found！");
		    $this->mod = new $extmod($module,$action);
        if(!method_exists($extmod,$action) === true) error("Module({$module})'s Action '$action' not found！");
		    if($action == 'template') error("Module({$module})'s Action '$action' is'not effective！");
		    if(@$this->mod->$action()) error("Module({$module})'s Action '$action' is'not effective！");
    }
	function display(){
		$this->mod->template();
	}
}
?>