Skip to content

Commit

Permalink
init: v4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yuantuo666 committed Sep 23, 2023
1 parent 21d4c84 commit 2d02f70
Show file tree
Hide file tree
Showing 74 changed files with 5,244 additions and 2 deletions.
1 change: 1 addition & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_DEBUG = trueDB_TYPE = mysqlDB_HOST = 127.0.0.1DB_NAME = testDB_USER = usernameDB_PASS = passwordDB_PORT = 3306DB_CHARSET = utf8DEFAULT_LANG = zh-cn
Expand Down
16 changes: 14 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
.vscode/
.idea/
*.log
.env
composer.phar
composer.lock
.DS_Store
Thumbs.db
/.idea
/.vscode
/vendor
/.settings
/.buildpath
/.project
public/update.json
bdwp.db
42 changes: 42 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
版权所有Copyright © 2006-2023 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.
1 change: 1 addition & 0 deletions app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
74 changes: 74 additions & 0 deletions app/Account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

/**
* 百度网盘账号管理
*/

namespace app;

class Account
{

public static function getBDUSS($cookie)
{
$BDUSS = "";
$STOKEN = "";
preg_match('/BDUSS=([^;]*)/i', $cookie, $matches);
if (isset($matches[1])) {
$BDUSS = $matches[1];
}
preg_match('/STOKEN=([^;]*)/i', $cookie, $matches);
if (isset($matches[1])) {
$STOKEN = $matches[1];
}
return [$BDUSS, $STOKEN];
}

/**
* 用于获取账号状态
*
* @return array [errno,会员状态,用户名,登录状态,会员剩余时间]
*/
public static function checkStatus($cookie)
{
// list($BDUSS, $STOKEN) = static::getBDUSS($cookie);
$Url = "https://pan.baidu.com/api/gettemplatevariable?channel=chunlei&web=1&app_id=250528&clienttype=0";
$Header = [
"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36",
"Cookie: $cookie"
];
$Data = "fields=[%22username%22,%22loginstate%22,%22is_vip%22,%22is_svip%22,%22is_evip%22]";
$Result = Req::POST($Url, $Data, $Header);
$Result = json_decode($Result, true);
if ($Result["errno"] == 0) {
// 正常
$Username = $Result["result"]["username"];
$LoginStatus = $Result["result"]["loginstate"];
if ($Result["result"]["is_vip"] == 1) {
$SVIP = 1; //会员账号
} elseif ($Result["result"]["is_svip"] == 1 or $Result["result"]["is_evip"] == 1) {
$SVIP = 2; //超级会员账号
} else {
$SVIP = 0; //普通账号
return array(0, $SVIP, $Username, $LoginStatus, 0);
}

$Url = "https://pan.baidu.com/rest/2.0/membership/user?channel=chunlei&web=1&app_id=250528&clienttype=0";
$Data = "method=query";
$Result = Req::POST($Url, $Data, $Header);
$Result = json_decode($Result, true);
if (isset($Result["reminder"]["svip"])) {
//存在会员信息
$LeftSeconds = $Result["reminder"]["svip"]["leftseconds"];
return array(0, $SVIP, $Username, $LoginStatus, $LeftSeconds);
}
return array(-1);
} elseif ($Result["errno"] == -6) {
// 账号失效
return array(-6);
} else {
//未知错误
return array($Result["errno"]);
}
}
}
22 changes: 22 additions & 0 deletions app/AppService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
declare (strict_types = 1);

namespace app;

use think\Service;

/**
* 应用服务类
*/
class AppService extends Service
{
public function register()
{
// 服务注册
}

public function boot()
{
// 服务启动
}
}
94 changes: 94 additions & 0 deletions app/BaseController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
declare (strict_types = 1);

namespace app;

use think\App;
use think\exception\ValidateException;
use think\Validate;

/**
* 控制器基础类
*/
abstract class BaseController
{
/**
* Request实例
* @var \think\Request
*/
protected $request;

/**
* 应用实例
* @var \think\App
*/
protected $app;

/**
* 是否批量验证
* @var bool
*/
protected $batchValidate = false;

/**
* 控制器中间件
* @var array
*/
protected $middleware = [];

/**
* 构造方法
* @access public
* @param App $app 应用对象
*/
public function __construct(App $app)
{
$this->app = $app;
$this->request = $this->app->request;

// 控制器初始化
$this->initialize();
}

// 初始化
protected function initialize()
{}

/**
* 验证数据
* @access protected
* @param array $data 数据
* @param string|array $validate 验证器名或者验证规则数组
* @param array $message 提示信息
* @param bool $batch 是否批量验证
* @return array|string|true
* @throws ValidateException
*/
protected function validate(array $data, string|array $validate, array $message = [], bool $batch = false)
{
if (is_array($validate)) {
$v = new Validate();
$v->rule($validate);
} else {
if (strpos($validate, '.')) {
// 支持场景
[$validate, $scene] = explode('.', $validate);
}
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
$v = new $class();
if (!empty($scene)) {
$v->scene($scene);
}
}

$v->message($message);

// 是否批量验证
if ($batch || $this->batchValidate) {
$v->batch(true);
}

return $v->failException(true)->check($data);
}

}
58 changes: 58 additions & 0 deletions app/ExceptionHandle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
namespace app;

use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\Handle;
use think\exception\HttpException;
use think\exception\HttpResponseException;
use think\exception\ValidateException;
use think\Response;
use Throwable;

/**
* 应用异常处理类
*/
class ExceptionHandle extends Handle
{
/**
* 不需要记录信息(日志)的异常类列表
* @var array
*/
protected $ignoreReport = [
HttpException::class,
HttpResponseException::class,
ModelNotFoundException::class,
DataNotFoundException::class,
ValidateException::class,
];

/**
* 记录异常信息(包括日志或者其它方式记录)
*
* @access public
* @param Throwable $exception
* @return void
*/
public function report(Throwable $exception): void
{
// 使用内置的方式记录异常日志
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @access public
* @param \think\Request $request
* @param Throwable $e
* @return Response
*/
public function render($request, Throwable $e): Response
{
// 添加自定义异常处理机制

// 其他错误交给系统处理
return parent::render($request, $e);
}
}
Loading

0 comments on commit 2d02f70

Please sign in to comment.