内核更新,多余文件清理

This commit is contained in:
2016-07-01 18:04:46 +08:00
parent a595f3a13e
commit 0398e5bd80
31 changed files with 426 additions and 551 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ namespace app\common\behavior;
class InitHook {
public function run(&$content){
public function run(&$request){
//初始化某些配置信息
if (cache('db_config_data')) {
+3 -1
View File
@@ -16,8 +16,10 @@ class Fornt extends Base{
//判读是否为关闭网站
if (\think\Config::get('web_site_close')) {
return $this->fetch('common@default/public/close');exit();
header("Content-type:text/html;charset=utf-8");
echo $this->fetch('common@default/public/close');exit();
}
//设置SEO
$this->setSeo();
+20
View File
@@ -0,0 +1,20 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\common\model;
/**
* 用户模型
*/
class MemberExtend extends Base{
protected $type = array(
'uid' => 'integer',
);
}
+33 -18
View File
@@ -12,19 +12,14 @@ namespace app\common\model;
/**
* 用户模型
*/
class User extends \think\model\Merge{
class User extends Base{
protected $name = "Member";
protected static $relationModel = array('MemberExtend');
protected $createTime = 'reg_time';
protected $updateTime = 'last_login_time';
protected $fk = 'user_id';
protected $mapFields = array(
'uid' => 'Member.uid',
'user_id' => 'MemberExtend.uid',
);
protected $type = array(
'id' => 'integer',
'uid' => 'integer',
);
protected $insert = array('salt', 'password', 'status', 'reg_time');
protected $update = array();
@@ -54,11 +49,21 @@ class User extends \think\model\Merge{
array('name'=>'nickname','title'=>'昵称','type'=>'text','help'=>''),
array('name'=>'sex','title'=>'性别','type'=>'select','option'=>array('0'=>'保密','1'=>'男','2'=>'女'),'help'=>''),
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
array('name'=>'mobile','title'=>'联系电话','type'=>'text','help'=>''),
array('name'=>'qq','title'=>'QQ','type'=>'text','help'=>''),
array('name'=>'score','title'=>'用户积分','type'=>'text','help'=>''),
array('name'=>'signature','title'=>'用户签名','type'=>'textarea','help'=>''),
);
public $userextend = array(
array('name'=>'company','title'=>'单位名称','type'=>'text','help'=>''),
array('name'=>'company_addr','title'=>'单位地址','type'=>'text','help'=>''),
array('name'=>'company_contact','title'=>'单位联系人','type'=>'text','help'=>''),
array('name'=>'company_zip','title'=>'单位邮编','type'=>'text','help'=>''),
array('name'=>'company_depart','title'=>'所属部门','type'=>'text','help'=>''),
array('name'=>'company_post','title'=>'所属职务','type'=>'text','help'=>''),
array('name'=>'company_type','title'=>'单位类型','type'=>'select', 'option'=>'', 'help'=>''),
);
protected function setStatusAttr($value){
return 1;
}
@@ -72,6 +77,11 @@ class User extends \think\model\Merge{
*/
public function login($username = '', $password = '', $type = 1){
$map = array();
if (\think\Validate::is($username,'email')) {
$type = 2;
}elseif (preg_match("/^1[34578]{1}\d{9}$/",$username)) {
$type = 3;
}
switch ($type) {
case 1:
$map['username'] = $username;
@@ -111,11 +121,6 @@ class User extends \think\model\Merge{
* @param integer $user 用户信息数组
*/
function register($username, $password, $repassword, $email, $isautologin = true){
if ($password !== $repassword) {
$this->error = "密码和确认密码不相同";
return false;
}
$data['username'] = $username;
$data['salt'] = rand_string(6);
$data['password'] = $password;
@@ -123,6 +128,7 @@ class User extends \think\model\Merge{
$result = $this->validate(true)->save($data);
if ($result) {
$this->data['uid'] = $result;
$this->extend()->save($data);
if ($isautologin) {
$this->autoLogin($this->data);
}
@@ -147,8 +153,8 @@ class User extends \think\model\Merge{
'last_login_time' => time(),
'last_login_ip' => get_client_ip(1),
);
$this->db()->where(array('uid'=>$user['uid']))->update($data);
$user = $this->db()->where(array('uid'=>$user['uid']))->find();
$this->where(array('uid'=>$user['uid']))->update($data);
$user = $this->where(array('uid'=>$user['uid']))->find();
/* 记录登录SESSION和COOKIES */
$auth = array(
@@ -167,7 +173,7 @@ class User extends \think\model\Merge{
}
public function getInfo($uid){
$data = $this->db()->where(array('uid'=>$uid))->find();
$data = $this->where(array('uid'=>$uid))->find();
if ($data) {
return $data->toArray();
}else{
@@ -178,7 +184,12 @@ class User extends \think\model\Merge{
public function change(){
$data = input('post.');
if ($data['uid']) {
return $this->save($data, array('uid'=>$data['uid']));
$result = $this->validate('member.edit')->save($data, array('uid'=>$data['uid']));
if ($result) {
$result = $this->extend->save($data, array('uid'=>$data['uid']));
}else{
return false;
}
}else{
$this->error = "非法操作!";
return false;
@@ -211,6 +222,10 @@ class User extends \think\model\Merge{
return $this->db()->where(array('uid'=>$uid))->update($data);
}
public function extend(){
return $this->hasOne('MemberExtend', 'uid');
}
protected function checkPassword($username,$password){
if (!$username || !$password) {
return false;
+7 -3
View File
@@ -15,17 +15,21 @@ namespace app\common\validate;
class Member extends \think\Validate{
protected $rule = array(
'username' => 'require|unique:member|/^[a-zA-Z]\w{0,39}$/',
'email' => 'require|unique:member|email',
'username' => 'require|unique:member|/^[a-zA-Z]\w{0,39}$/',
'email' => 'require|unique:member|email',
'mobile' => 'unique:member',
'repassword'=>'require|confirm:password'
);
protected $message = array(
'username.require' => '用户名必须',
'username.unique' => '用户名已存在',
'email.require' => '邮箱必须',
'email.unique' => '邮箱已存在',
'mobile.unique' => '手机号已存在',
'repassword.require' => '确认密码和密码必须一致',
);
protected $scene = array(
//'add' => 'username,email',
'edit' => 'email,mobile',
);
}
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SentCMS网站管理系统 - PowerBy TenSent</title>
<style>
body{font-family: "微软雅黑","Microsoft Yahei";}
.close{border: 5px solid #efefef; padding: 30px; width: 300px; margin: 100px auto; text-align: center;}
</style>
</head>
<body>
<div class="close">
本站已关闭!
</div>
</body>
</html>