<commit_before><?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CI RBAC
 * 模型
 * @author		toryzen
 * @link		http://www.toryzen.com
 */
class Rbac_model extends CI_Model{
	
	public function __construct(){
		parent::__construct();
		$this->load->database();
	}
	
	/*
	 * 获取权限列表
	*/
	public function get_acl($role_id){
		$query = $this->db->query("SELECT node_id,directory,controller,func FROM Node WHERE node_id in (SELECT node_id FROM Authorizes WHERE rid = ".$role_id.")");
		$role_data = $query->result();
		foreach($role_data as $vo){
			$Tmp_role[$vo->directory][$vo->controller][$vo->func] = TRUE;
		}
		rbac_conf(array('ACL'),$Tmp_role);
	}
	
	/*
	 * 用户登录检测
	*/
	public function check_user($uid,$password){
		$query = $this->db->query("SELECT uid,password,phone,email,rid,status FROM User WHERE uid = '".$uid."' LIMIT 1");
		$data  = $query->row_array();
		if($data){
			if($data['status']==1){
				if($data['password']==$password){
					rbac_conf(array('INFO','uid'),$data['uid']);
					rbac_conf(array('INFO','rid'),$data['rid']);
					rbac_conf(array('INFO','email'),$data['email']);
					rbac_conf(array('INFO','phone'),$data['phone']);
					$this->get_acl($data['rid']);
					return TRUE;
				}<commit_msg>Update rbac_model.php<commit_after><?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Rbac_model extends CI_Model{
	
	public function __construct(){
		parent::__construct();
		$this->load->database();
	}
	
	/*
	 * Get privileges list
	*/
	public function get_acl($role_id){
		$query = $this->db->query("SELECT node_id,directory,controller,func FROM Node WHERE node_id in (SELECT node_id FROM Authorizes WHERE rid = ".$role_id.")");
		$role_data = $query->result();
		foreach($role_data as $vo){
			$Tmp_role[$vo->directory][$vo->controller][$vo->func] = TRUE;
		}
		rbac_conf(array('ACL'),$Tmp_role);
	}
	
	/*
	 * check user
	*/
	public function check_user($uid,$password){
		$query = $this->db->query("SELECT uid,password,phone,email,rid,status FROM User WHERE uid = '".$uid."' LIMIT 1");
		$data  = $query->row_array();
		if($data){
			if($data['status']==1){
				if($data['password']==$password){
					rbac_conf(array('INFO','uid'),$data['uid']);
					rbac_conf(array('INFO','rid'),$data['rid']);
					rbac_conf(array('INFO','email'),$data['email']);
					rbac_conf(array('INFO','phone'),$data['phone']);
					$this->get_acl($data['rid']);
					return TRUE;
				}
{'fraction_non_alphanumeric': 0.2152777777777778, 'fraction_numerical': 0.0016339869281045752, 'mean_word_length': 4.844868735083533, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7583436', 'n_tokens_mistral': 967, 'n_tokens_neox': 865, 'n_words': 151}