目录结构更新,增加composer支持

This commit is contained in:
2018-01-14 09:41:28 +08:00
parent ae46a73172
commit 0c7d06de51
29 changed files with 506 additions and 0 deletions

1
application/.htaccess Normal file
View File

@@ -0,0 +1 @@
deny from all

View File

@@ -0,0 +1,7 @@
<?php
namespace app\admin\controller;
class Goods
{
}

View File

@@ -0,0 +1 @@
<?php

12
application/command.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------
return [];

View File

@@ -0,0 +1 @@
<?php

View File

@@ -0,0 +1,5 @@
<?php
//配置文件
return [
];

View File

@@ -0,0 +1,158 @@
<?php
namespace app\common\model;
class Member extends Base {
protected $createTime = 'reg_time';
protected $updateTime = 'last_login_time';
protected $insert = array('status'=>1, 'reg_time');
protected $type = array(
'uid' => 'integer',
'reg_time' => 'integer'
);
protected function getGroupListAttr($value, $data){
$sql = db('AuthGroupAccess')->where('uid', $data['uid'])->fetchSql(true)->column('group_id');
return db('AuthGroup')->where('id in ('.$sql.')')->column('title', 'id');
}
/**
* 用户登录模型
* @param string $username [description]
* @param string $password [description]
* @param integer $type 登录类型1为用户名登录2为邮箱登录3为手机登录4为用户ID登录5为微信登录
* @return [type] [description]
*/
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;
break;
case 2:
$map['email'] = $username;
break;
case 3:
$map['mobile'] = $username;
break;
case 4:
$map['uid'] = $username;
break;
case 5:
$map['openid'] = $username;
break;
default:
return 0; //参数错误
}
if (!$username) {
return false;
}
$user = $this->where($map)->find();
if (isset($user['uid']) && $user['uid'] && $user['status']) {
if ($type == 3) {
//手机验证手机动态密码
if ($password == session('mobile_login_code')) {
$this->autoLogin($user); //更新用户登录信息
return $user['uid'];
}else{
return -5;
}
} elseif ($type == 5) {
$this->autoLogin($user); //更新用户登录信息
return $user['uid'];
} else {
/* 验证用户密码 */
if (md5($password . $user['salt']) === $user['password']) {
$this->autoLogin($user); //更新用户登录信息
return $user['uid']; //登录成功返回用户ID
} else {
return -2; //密码错误
}
}
} else {
if ($type == 3 && preg_match("/^1[34578]{1}\d{9}$/", $username) && $password == session('mobile_login_code')) {
$data = array(
'username' => $username,
'mobile' => $username,
'salt' => rand_string(6),
'password' => $password,
);
$result = $this->save($data);
if ($result) {
$this->autoLogin($this->data); //更新用户登录信息
}
return $this->data['uid'];
} else {
return -1; //用户不存在或被禁用
}
}
}
/**
* 用户注册
* @param integer $user 用户信息数组
*/
function register($username, $password, $repassword, $email, $isautologin = true, $other = array()){
$data['username'] = $username;
$data['salt'] = rand_string(6);
$data['password'] = $password;
$data['repassword'] = $repassword;
$data['email'] = $email;
if (!empty($other)) {
$data = array_merge($data, $other);
}
$result = $this->validate(true)->save($data);
if ($result) {
$data['uid'] = $this->data['uid'];
if ($isautologin) {
$this->autoLogin($this->data);
}
return $result;
}else{
if (!$this->getError()) {
$this->error = "注册失败!";
}
return false;
}
}
/**
* 自动登录用户
* @param integer $user 用户信息数组
*/
private function autoLogin($user){
/* 更新登录信息 */
$data = array(
'uid' => $user['uid'],
'login' => array('exp', '`login`+1'),
'last_login_time' => time(),
'last_login_ip' => get_client_ip(1),
);
$this->where(array('uid'=>$user['uid']))->update($data);
$user = $this->where(array('uid'=>$user['uid']))->find();
/* 记录登录SESSION和COOKIES */
$auth = array(
'uid' => $user['uid'],
'username' => $user['username'],
'last_login_time' => $user['last_login_time'],
);
session('user_auth', $auth);
session('user_auth_sign', data_auth_sign($auth));
}
public function logout(){
session('user_auth', null);
session('user_auth_sign', null);
}
}

View File

@@ -0,0 +1,18 @@
<?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>
// +----------------------------------------------------------------------
return [
// 验证码字体大小
'fontSize' => 25,
// 验证码位数
'length' => 3,
// 关闭验证码杂点
'useNoise' => false,
'useZh' => true
];

View File

@@ -0,0 +1,28 @@
<?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>
// +----------------------------------------------------------------------
return [
'text' => ['title' => '单行文本', 'type' => 'varchar'],
'string' => ['title' => '字符串', 'type' => 'int'],
'password' => ['title' => '密码', 'type' => 'varchar'],
'textarea' => ['title' => '文本框', 'type' => 'text'],
'bool' => ['title' => '布尔型', 'type' => 'int'],
'select' => ['title' => '选择', 'type' => 'varchar'],
'num' => ['title' => '数字', 'type' => 'int'],
'decimal' => ['title' => '金额', 'type' => 'decimal'],
'tags' => ['title' => '标签', 'type' => 'varchar'],
'datetime' => ['title' => '时间控件', 'type' => 'int'],
'date' => ['title' => '日期控件', 'type' => 'varchar'],
'editor' => ['title' => '编辑器', 'type' => 'text'],
'bind' => ['title' => '模型绑定', 'type' => 'int'],
'image' => ['title' => '图片上传', 'type' => 'int'],
'images' => ['title' => '多图上传', 'type' => 'varchar'],
'attach' => ['title' => '文件上传', 'type' => 'varchar'],
];

View File

@@ -0,0 +1,6 @@
<?php
return array(
'template' => array(
'view_depr' => '_'
)
);

View File

@@ -0,0 +1,37 @@
<?php
namespace app\index\controller;
use EasyWeChat\Factory;
/**
* 微信
*/
class Wechat {
public function __construct() {
$this->options = [
'app_id' => 'wx3cf0f39249eb0exxx',
'secret' => 'f1c242f4f28f735d4687abb469072xxx',
'token' => 'easywechat',
'log' => [
'level' => 'debug',
'file' => RUNTIME_PATH . '/easywechat.log',
],
];
}
public function index(){
$app = Factory::officialAccount($this->options);
$server = $app->server;
$user = $app->user;
// $server->push(function($message) use ($user) {
// $fromUser = $user->get($message['FromUserName']);
// return "{$fromUser->nickname} 您好!欢迎关注 overtrue!";
// });
$server->serve()->send();
}
}

View File

@@ -0,0 +1 @@
<?php

View File

@@ -0,0 +1,5 @@
<?php
//配置文件
return [
];