-
Notifications
You must be signed in to change notification settings - Fork 7
Home
lee409 edited this page Sep 6, 2016
·
1 revision
关键代码片段
checkPwd ()) { $this->output_error_json ( L ( 'account_error' ), 20205 ); } $this->output_success_json('查询成功', 0); } /** * 验证密码 */ private function checkPwd() { $model = pc_base::load_apimodel ( 'account_model' ); $success = false; if($model->fetchPwd ( $this->data () )==$this->data()['password']){ $success = true; } return $success; } } db_config = pc_base::load_config('database'); $this->db_setting = 'default'; $this->table_name = 'member'; parent::__construct(); } /** * 重置模型操作表表 * @param string $modelid 模型id */ public function set_model($modelid = '') { if($modelid) { $model = getcache('member_model', 'commons'); if(isset($model[$modelid])) { $this->table_name = $this->db_tablepre.$model[$modelid]['tablename']; } else { $this->table_name = $this->db_tablepre.$model[10]['tablename']; } } else { $this->table_name = $this->db_tablepre.'member'; } } /** * 查询密码 * * @param array $data * @return multitype:Ambigous |boolean */ public function fetchPwd($data) { if (empty ( $data ['account'] )) { return false; } else { $tablename = $this->db_tablepre . 'member'; $member_info = $this->get_one ( array ( 'username' => $data ['account'] ) ); return $member_info ['password']; } } } /** * 加载数据模型 * @param string $classname 类名 */ public static function load_apimodel($classname) { return self::_load_api_class($classname,'/api/model/'); } /** * 加载类文件api函数 * @param string $classname 类名 * @param string $path 扩展地址 * @param intger $initialize 是否初始化 */ private static function _load_api_class($classname, $path = '', $initialize = 1) { static $classes = array(); if (empty($path)) $path = 'libs'.DIRECTORY_SEPARATOR.'classes'; $key = md5($path.$classname); if (isset($classes[$key])) { if (!empty($classes[$key])) { return $classes[$key]; } else { return true; } } if (file_exists(PHPCMS_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php')) { include PHPCMS_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php'; $name = $classname; if ($my_path = self::my_path(PHPCMS_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php')) { include $my_path; $name = 'MY_'.$classname; } if ($initialize) { $classes[$key] = new $name; } else { $classes[$key] = true; } return $classes[$key]; } else { return false; } } http://www.lxm.com/live_demo/index.php http://www.lxm.com/live_demo/index.php?m=admin&c=index&pc_hash=TBG75D