diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..36f7b6f9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +sudo: false + +language: php + +branches: + only: + - stable + +cache: + directories: + - $HOME/.composer/cache + +before_install: + - composer self-update + +install: + - composer install --no-dev --no-interaction --ignore-platform-reqs + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip . + - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0" + - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0" + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip . + +script: + - php think unit + +deploy: + provider: releases + api_key: + secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw= + file: + - ThinkPHP_Core.zip + - ThinkPHP_Full.zip + skip_cleanup: true + on: + tags: true diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..2cb9a8a9 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,32 @@ + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 +版权所有Copyright © 2006-2017 by ThinkPHP (http://thinkphp.cn) +All rights reserved。 +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +Apache Licence是著名的非盈利开源组织Apache采用的协议。 +该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, +允许代码修改,再作为开源或商业软件发布。需要满足 +的条件: +1. 需要给代码的用户一份Apache Licence ; +2. 如果你修改了代码,需要在被修改的文件中说明; +3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 +带有原来代码中的协议,商标,专利声明和其他原来作者规 +定需要包含的说明; +4. 如果再发布的产品中包含一个Notice文件,则在Notice文 +件中需要带有本协议内容。你可以在Notice中增加自己的 +许可,但不可以表现为对Apache Licence构成更改。 +具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/application/.htaccess b/application/.htaccess new file mode 100644 index 00000000..3418e55a --- /dev/null +++ b/application/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/application/admin/controller/Goods.php b/application/admin/controller/Goods.php new file mode 100644 index 00000000..25277686 --- /dev/null +++ b/application/admin/controller/Goods.php @@ -0,0 +1,7 @@ + +// +---------------------------------------------------------------------- + +return []; diff --git a/application/common/common.php b/application/common/common.php new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/application/common/common.php @@ -0,0 +1 @@ +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); + } +} \ No newline at end of file diff --git a/application/extra/captcha.php b/application/extra/captcha.php new file mode 100644 index 00000000..69d50495 --- /dev/null +++ b/application/extra/captcha.php @@ -0,0 +1,18 @@ + +// +---------------------------------------------------------------------- + +return [ + // 验证码字体大小 + 'fontSize' => 25, + // 验证码位数 + 'length' => 3, + // 关闭验证码杂点 + 'useNoise' => false, + 'useZh' => true +]; \ No newline at end of file diff --git a/application/extra/fieldType.php b/application/extra/fieldType.php new file mode 100644 index 00000000..5b05cc82 --- /dev/null +++ b/application/extra/fieldType.php @@ -0,0 +1,28 @@ + +// +---------------------------------------------------------------------- + + +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'], +]; \ No newline at end of file diff --git a/application/index/config.php b/application/index/config.php new file mode 100644 index 00000000..a37b1a57 --- /dev/null +++ b/application/index/config.php @@ -0,0 +1,6 @@ + array( + 'view_depr' => '_' + ) +); \ No newline at end of file diff --git a/application/index/controller/Wechat.php b/application/index/controller/Wechat.php new file mode 100644 index 00000000..7c63a8e2 --- /dev/null +++ b/application/index/controller/Wechat.php @@ -0,0 +1,37 @@ +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(); + } +} \ No newline at end of file diff --git a/application/user/common.php b/application/user/common.php new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/application/user/common.php @@ -0,0 +1 @@ + +// +---------------------------------------------------------------------- + +return [ + // 生成应用公共文件 + '__file__' => ['common.php', 'config.php', 'database.php'], + + // 定义demo模块的自动生成 (按照实际定义的文件名生成) + 'admin' => [ + // '__file__' => ['common.php'], + '__dir__' => ['behavior', 'controller', 'model', 'view'], + 'controller' => ['Fornt', 'Admin', 'Base', 'User'], + 'model' => ['User', 'UserType'], + //'view' => ['index/index'], + ], + 'user' => [ + '__dir__' => ['controller'], + ] + // 其他更多的模块定义 +]; diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..d5269bd2 --- /dev/null +++ b/composer.json @@ -0,0 +1,41 @@ +{ + "name": "topthink/think", + "description": "the new thinkphp framework", + "type": "project", + "keywords": [ + "framework", + "thinkphp", + "ORM" + ], + "homepage": "http://thinkphp.cn/", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "require": { + "php": ">=5.4.0", + "topthink/framework": "5.0.*", + "topthink/think-migration": "^2.0", + "topthink/think-captcha": "1.0.7", + "topthink/think-image": "^1.0", + "topthink/think-helper": "^1.0", + "overtrue/wechat": "~4.0", + "overtrue/easy-sms": "^1.0", + "riverslei/payment": "*", + "5ini99/think-auth": "^1.0" + }, + "autoload": { + "psr-4": { + "app\\": "application" + } + }, + "extra": { + "think-path": "framework" + }, + "config": { + "preferred-install": "dist" + } +} diff --git a/extend/.gitignore b/extend/.gitignore new file mode 100644 index 00000000..c96a04f0 --- /dev/null +++ b/extend/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/think b/think new file mode 100644 index 00000000..fdf68915 --- /dev/null +++ b/think @@ -0,0 +1,17 @@ +#!/usr/bin/env php + +// +---------------------------------------------------------------------- + +// 定义项目路径 +define('APP_PATH', __DIR__ . '/application/'); + +// 加载框架引导文件 +require __DIR__.'/framework/console.php'; diff --git a/web/.htaccess b/web/.htaccess new file mode 100644 index 00000000..cbc78689 --- /dev/null +++ b/web/.htaccess @@ -0,0 +1,8 @@ + + Options +FollowSymlinks -Multiviews + RewriteEngine On + + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] + diff --git a/web/favicon.ico b/web/favicon.ico new file mode 100644 index 00000000..fa46e5eb Binary files /dev/null and b/web/favicon.ico differ diff --git a/web/index.php b/web/index.php new file mode 100644 index 00000000..b0165ce7 --- /dev/null +++ b/web/index.php @@ -0,0 +1,24 @@ + +// +---------------------------------------------------------------------- + +// [ 应用入口文件 ] +if(version_compare(PHP_VERSION,'5.4.0','<')) die('require PHP > 5.4.0 !'); + +// 定义应用目录 +define('APP_PATH', __DIR__ . '/../application/'); +define('BASE_PATH', substr($_SERVER['SCRIPT_NAME'], 0, -10)); + +/** + * 缓存目录设置 + * 此目录必须可写,建议移动到非WEB目录 + */ +define ( 'RUNTIME_PATH', __DIR__ . '/../data/' ); + +// 加载框架引导文件 +require __DIR__ . '/../framework/start.php'; diff --git a/web/robots.txt b/web/robots.txt new file mode 100644 index 00000000..eb053628 --- /dev/null +++ b/web/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/web/router.php b/web/router.php new file mode 100644 index 00000000..f81dd618 --- /dev/null +++ b/web/router.php @@ -0,0 +1,17 @@ + +// +---------------------------------------------------------------------- + +if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) { + return false; +} else { + if (!isset($_SERVER['PATH_INFO'])) { + $_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI']; + } + require __DIR__ . "/index.php"; +} diff --git a/web/static/.gitignore b/web/static/.gitignore new file mode 100644 index 00000000..c96a04f0 --- /dev/null +++ b/web/static/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/web/template/default/index_index.html b/web/template/default/index_index.html new file mode 100644 index 00000000..e2d7a0db --- /dev/null +++ b/web/template/default/index_index.html @@ -0,0 +1 @@ +{__TPL__} \ No newline at end of file diff --git a/web/template/default/info.php b/web/template/default/info.php new file mode 100644 index 00000000..2202f053 --- /dev/null +++ b/web/template/default/info.php @@ -0,0 +1,9 @@ + '默认模板', //模板名称 + 'remark' => '模板名称.', // 模板简单介绍 + 'img' => 'logo.png', // 后台显示模板缩列图 相对于模板目录路径 + 'type' => 'pc', //模板类型,pc为PC端模板,mobile为手机端模板 + 'version' => 'v1', // 模板版本 + 'author' => '郭平平', // 作者 +); \ No newline at end of file diff --git a/web/template/default/logo.png b/web/template/default/logo.png new file mode 100644 index 00000000..6a99fd46 Binary files /dev/null and b/web/template/default/logo.png differ diff --git a/web/template/default/user/index.html b/web/template/default/user/index.html new file mode 100644 index 00000000..61de0edf --- /dev/null +++ b/web/template/default/user/index.html @@ -0,0 +1 @@ +测试 \ No newline at end of file