├── thinkphp ├── .htaccess ├── .gitignore ├── logo.png ├── library │ ├── think │ │ ├── console │ │ │ ├── bin │ │ │ │ ├── hiddeninput.exe │ │ │ │ └── README.md │ │ │ ├── command │ │ │ │ ├── make │ │ │ │ │ ├── stubs │ │ │ │ │ │ ├── model.stub │ │ │ │ │ │ ├── controller.plain.stub │ │ │ │ │ │ └── controller.stub │ │ │ │ │ ├── Model.php │ │ │ │ │ └── Controller.php │ │ │ │ ├── Build.php │ │ │ │ ├── Clear.php │ │ │ │ ├── Help.php │ │ │ │ ├── Lists.php │ │ │ │ ├── optimize │ │ │ │ │ ├── Route.php │ │ │ │ │ └── Config.php │ │ │ │ └── Make.php │ │ │ ├── LICENSE │ │ │ ├── output │ │ │ │ ├── driver │ │ │ │ │ ├── Nothing.php │ │ │ │ │ └── Buffer.php │ │ │ │ ├── question │ │ │ │ │ └── Confirmation.php │ │ │ │ └── formatter │ │ │ │ │ └── Stack.php │ │ │ └── input │ │ │ │ └── Argument.php │ │ ├── exception │ │ │ ├── RouteNotFoundException.php │ │ │ ├── HttpResponseException.php │ │ │ ├── ClassNotFoundException.php │ │ │ ├── TemplateNotFoundException.php │ │ │ ├── ValidateException.php │ │ │ ├── HttpException.php │ │ │ ├── DbException.php │ │ │ ├── PDOException.php │ │ │ ├── ThrowableError.php │ │ │ └── ErrorException.php │ │ ├── config │ │ │ └── driver │ │ │ │ ├── Ini.php │ │ │ │ ├── Json.php │ │ │ │ └── Xml.php │ │ ├── log │ │ │ └── driver │ │ │ │ └── Test.php │ │ ├── db │ │ │ ├── exception │ │ │ │ ├── BindParamException.php │ │ │ │ ├── ModelNotFoundException.php │ │ │ │ └── DataNotFoundException.php │ │ │ ├── Expression.php │ │ │ ├── builder │ │ │ │ ├── Sqlite.php │ │ │ │ └── Pgsql.php │ │ │ └── connector │ │ │ │ ├── Sqlite.php │ │ │ │ ├── Pgsql.php │ │ │ │ └── pgsql.sql │ │ ├── model │ │ │ ├── Pivot.php │ │ │ ├── Collection.php │ │ │ └── Relation.php │ │ ├── Env.php │ │ ├── controller │ │ │ ├── Yar.php │ │ │ └── Rest.php │ │ ├── process │ │ │ ├── exception │ │ │ │ ├── Failed.php │ │ │ │ └── Timeout.php │ │ │ ├── Utils.php │ │ │ └── pipes │ │ │ │ └── Pipes.php │ │ ├── response │ │ │ ├── Json.php │ │ │ ├── Jsonp.php │ │ │ ├── View.php │ │ │ ├── Redirect.php │ │ │ └── Xml.php │ │ ├── Exception.php │ │ ├── template │ │ │ └── driver │ │ │ │ └── File.php │ │ ├── session │ │ │ └── driver │ │ │ │ ├── Memcache.php │ │ │ │ ├── Redis.php │ │ │ │ └── Memcached.php │ │ └── Error.php │ └── traits │ │ └── think │ │ └── Instance.php ├── codecov.yml ├── start.php ├── console.php ├── composer.json ├── tpl │ ├── default_index.tpl │ └── dispatch_jump.tpl ├── .travis.yml ├── phpunit.xml ├── LICENSE.txt ├── base.php ├── CONTRIBUTING.md └── README.md ├── application ├── .htaccess ├── index │ ├── controller │ │ ├── Index.php │ │ ├── Command.php │ │ ├── User.php │ │ ├── Content.php │ │ └── Base.php │ └── view │ │ ├── base │ │ ├── header.html │ │ ├── left.html │ │ ├── nav.html │ │ └── page.html │ │ ├── command │ │ └── index.html │ │ ├── action │ │ ├── delete.html │ │ ├── timeset.html │ │ ├── addnew.html │ │ └── select.html │ │ ├── index │ │ ├── content.html │ │ └── index.html │ │ └── db │ │ └── dbindex.html ├── common.php ├── command.php ├── route.php ├── tags.php └── database.php ├── extend └── .gitignore ├── public ├── robots.txt ├── favicon.ico ├── static │ ├── img │ │ └── favicon.png │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ └── js │ │ └── npm.js ├── .htaccess ├── index.php └── router.php ├── .gitignore ├── vendor ├── topthink │ └── think-installer │ │ ├── .gitignore │ │ ├── composer.json │ │ └── src │ │ ├── Plugin.php │ │ ├── ThinkFramework.php │ │ ├── ThinkTesting.php │ │ └── ThinkExtend.php ├── autoload.php └── composer │ ├── autoload_classmap.php │ ├── autoload_namespaces.php │ ├── autoload_psr4.php │ ├── LICENSE │ ├── autoload_static.php │ ├── autoload_real.php │ └── installed.json ├── composer.json ├── .project ├── License ├── README.md └── .travis.yml /thinkphp/.htaccess: -------------------------------------------------------------------------------- 1 | deny from all -------------------------------------------------------------------------------- /application/.htaccess: -------------------------------------------------------------------------------- 1 | deny from all -------------------------------------------------------------------------------- /extend/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | composer.lock 3 | *.log 4 | /runtime 5 | -------------------------------------------------------------------------------- /thinkphp/.gitignore: -------------------------------------------------------------------------------- 1 | /composer.lock 2 | /vendor 3 | .idea 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /vendor/topthink/think-installer/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | composer.lock 3 | /vendor -------------------------------------------------------------------------------- /thinkphp/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void9main/SeeRedis/HEAD/thinkphp/logo.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void9main/SeeRedis/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/static/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void9main/SeeRedis/HEAD/public/static/img/favicon.png -------------------------------------------------------------------------------- /public/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void9main/SeeRedis/HEAD/public/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /public/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void9main/SeeRedis/HEAD/public/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /thinkphp/library/think/console/bin/hiddeninput.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void9main/SeeRedis/HEAD/thinkphp/library/think/console/bin/hiddeninput.exe -------------------------------------------------------------------------------- /public/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void9main/SeeRedis/HEAD/public/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /public/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void9main/SeeRedis/HEAD/public/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /thinkphp/library/think/console/bin/README.md: -------------------------------------------------------------------------------- 1 | console 工具使用 hiddeninput.exe 在 windows 上隐藏密码输入,该二进制文件由第三方提供,相关源码和其他细节可以在 [Hidden Input](https://github.com/Seldaek/hidden-input) 找到。 2 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/make/stubs/model.stub: -------------------------------------------------------------------------------- 1 | 2 | Options +FollowSymlinks -Multiviews 3 | RewriteEngine On 4 | 5 | RewriteCond %{REQUEST_FILENAME} !-d 6 | RewriteCond %{REQUEST_FILENAME} !-f 7 | RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 8 | 9 | -------------------------------------------------------------------------------- /thinkphp/codecov.yml: -------------------------------------------------------------------------------- 1 | comment: 2 | layout: header, changes, diff 3 | coverage: 4 | ignore: 5 | - base.php 6 | - helper.php 7 | - convention.php 8 | - lang/zh-cn.php 9 | - start.php 10 | - console.php 11 | status: 12 | patch: false 13 | -------------------------------------------------------------------------------- /application/index/controller/Index.php: -------------------------------------------------------------------------------- 1 | fetch('index/index'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /application/index/view/base/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SeeRedis 6 | -------------------------------------------------------------------------------- /vendor/composer/autoload_psr4.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/topthink/think-installer/src'), 10 | 'think\\' => array($baseDir . '/thinkphp/library/think'), 11 | 'app\\' => array($baseDir . '/application'), 12 | ); 13 | -------------------------------------------------------------------------------- /public/static/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /application/common.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // 应用公共文件 13 | -------------------------------------------------------------------------------- /vendor/topthink/think-installer/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "topthink/think-installer", 3 | "type": "composer-plugin", 4 | "require": { 5 | "composer-plugin-api": "^1.0" 6 | }, 7 | "require-dev": { 8 | "composer/composer": "1.0.*@dev" 9 | }, 10 | "license": "Apache-2.0", 11 | "authors": [ 12 | { 13 | "name": "yunwuxin", 14 | "email": "448901948@qq.com" 15 | } 16 | ], 17 | "autoload": { 18 | "psr-4": { 19 | "think\\composer\\": "src" 20 | } 21 | }, 22 | "extra": { 23 | "class": "think\\composer\\Plugin" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /application/command.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return []; 13 | -------------------------------------------------------------------------------- /vendor/topthink/think-installer/src/Plugin.php: -------------------------------------------------------------------------------- 1 | getInstallationManager(); 15 | 16 | //框架核心 17 | $manager->addInstaller(new ThinkFramework($io, $composer)); 18 | 19 | //单元测试 20 | $manager->addInstaller(new ThinkTesting($io, $composer)); 21 | 22 | //扩展 23 | $manager->addInstaller(new ThinkExtend($io, $composer)); 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /thinkphp/start.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | // ThinkPHP 引导文件 15 | // 1. 加载基础文件 16 | require __DIR__ . '/base.php'; 17 | 18 | // 2. 执行应用 19 | App::run()->send(); 20 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // [ 应用入口文件 ] 13 | 14 | // 定义应用目录 15 | define('APP_PATH', __DIR__ . '/../application/'); 16 | // 加载框架引导文件 17 | require __DIR__ . '/../thinkphp/start.php'; 18 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "topthink/think", 3 | "description": "the new thinkphp framework", 4 | "type": "project", 5 | "keywords": [ 6 | "framework", 7 | "thinkphp", 8 | "ORM" 9 | ], 10 | "homepage": "http://thinkphp.cn/", 11 | "license": "Apache-2.0", 12 | "authors": [ 13 | { 14 | "name": "liu21st", 15 | "email": "liu21st@gmail.com" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=5.4.0", 20 | "topthink/framework": "5.0.*" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "app\\": "application" 25 | } 26 | }, 27 | "extra": { 28 | "think-path": "thinkphp" 29 | }, 30 | "config": { 31 | "preferred-install": "dist" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /thinkphp/console.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | // ThinkPHP 引导文件 15 | // 加载基础文件 16 | require __DIR__ . '/base.php'; 17 | 18 | // 执行应用 19 | App::initCommon(); 20 | Console::init(); 21 | -------------------------------------------------------------------------------- /application/index/controller/Command.php: -------------------------------------------------------------------------------- 1 | assign('dbNum',$this->dbinfoNum); 16 | 17 | if(!empty($address)){ 18 | 19 | $addArr = json_decode($address,true); 20 | 21 | $ip = $addArr['ip']; 22 | 23 | $port = $addArr['port']; 24 | 25 | }else{ 26 | 27 | $ip = "unknow"; 28 | 29 | $port = "unknow"; 30 | 31 | } 32 | 33 | $this->assign("ip",$ip); 34 | 35 | $this->assign("port",$port); 36 | 37 | 38 | return $this->fetch('command/index'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /application/index/view/base/left.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 14 |

15 | void9main 16 | | github: 17 | 18 | https://github.com/void9main/SeeRedis 19 | 20 |

21 |
22 |
-------------------------------------------------------------------------------- /application/index/view/command/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {include file="base/header" /} 5 | 6 | 25 | 26 | {include file="base/nav" /} 27 | {include file="base/left" /} 28 |
29 |
30 |
31 |

~$ redis-server:{$ip},port:{$port}

32 |
33 |
34 |
35 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/RouteNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class RouteNotFoundException extends HttpException 15 | { 16 | 17 | public function __construct() 18 | { 19 | parent::__construct(404, 'Route Not Found'); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /public/router.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | // $Id$ 12 | 13 | if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) { 14 | return false; 15 | } else { 16 | if (!isset($_SERVER['PATH_INFO'])) { 17 | $_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI']; 18 | } 19 | require __DIR__ . "/index.php"; 20 | } 21 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SeeRedis 4 | 5 | 6 | 7 | 8 | 9 | com.aptana.editor.php.aptanaPhpBuilder 10 | 11 | 12 | 13 | 14 | com.aptana.ide.core.unifiedBuilder 15 | 16 | 17 | 18 | 19 | 20 | com.aptana.projects.webnature 21 | com.aptana.editor.php.phpNature 22 | 23 | 24 | 25 | 1547458474735 26 | 27 | 26 28 | 29 | org.eclipse.ui.ide.multiFilter 30 | 1.0-name-matches-false-false-node_modules 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /thinkphp/library/think/config/driver/Ini.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\config\driver; 13 | 14 | class Ini 15 | { 16 | public function parse($config) 17 | { 18 | if (is_file($config)) { 19 | return parse_ini_file($config, true); 20 | } else { 21 | return parse_ini_string($config, true); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /thinkphp/library/think/config/driver/Json.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\config\driver; 13 | 14 | class Json 15 | { 16 | public function parse($config) 17 | { 18 | if (is_file($config)) { 19 | $config = file_get_contents($config); 20 | } 21 | $result = json_decode($config, true); 22 | return $result; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /thinkphp/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "topthink/framework", 3 | "description": "the new thinkphp framework", 4 | "type": "think-framework", 5 | "keywords": [ 6 | "framework", 7 | "thinkphp", 8 | "ORM" 9 | ], 10 | "homepage": "http://thinkphp.cn/", 11 | "license": "Apache-2.0", 12 | "authors": [ 13 | { 14 | "name": "liu21st", 15 | "email": "liu21st@gmail.com" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=5.4.0", 20 | "topthink/think-installer": "~1.0" 21 | }, 22 | "require-dev": { 23 | "phpunit/phpunit": "4.8.*", 24 | "johnkary/phpunit-speedtrap": "^1.0", 25 | "mikey179/vfsStream": "~1.6", 26 | "phploc/phploc": "2.*", 27 | "sebastian/phpcpd": "2.*", 28 | "phpdocumentor/reflection-docblock": "^2.0" 29 | }, 30 | "autoload": { 31 | "psr-4": { 32 | "think\\": "library/think" 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /thinkphp/library/think/log/driver/Test.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\log\driver; 13 | 14 | /** 15 | * 模拟测试输出 16 | */ 17 | class Test 18 | { 19 | /** 20 | * 日志写入接口 21 | * @access public 22 | * @param array $log 日志信息 23 | * @return bool 24 | */ 25 | public function save(array $log = []) 26 | { 27 | return true; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /application/route.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // 应用行为扩展定义文件 13 | return [ 14 | // 应用初始化 15 | 'app_init' => [], 16 | // 应用开始 17 | 'app_begin' => [], 18 | // 模块初始化 19 | 'module_init' => [], 20 | // 操作开始执行 21 | 'action_begin' => [], 22 | // 视图内容过滤 23 | 'view_filter' => [], 24 | // 日志写入 25 | 'log_write' => [], 26 | // 应用结束 27 | 'app_end' => [], 28 | ]; 29 | -------------------------------------------------------------------------------- /thinkphp/tpl/default_index.tpl: -------------------------------------------------------------------------------- 1 | *{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

:)

ThinkPHP V5
十年磨一剑 - 为API开发设计的高性能框架

[ V5.0 版本由 七牛云 独家赞助发布 ]
'; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /application/index/controller/User.php: -------------------------------------------------------------------------------- 1 | error("密码不能为空",url('')); 22 | 23 | exit; 24 | } 25 | 26 | if(md5($password) != config("password")){ 27 | 28 | $this->error("密码错误",url('')); 29 | 30 | exit; 31 | 32 | }else{ 33 | 34 | Session::set("name_login",md5(time())); 35 | 36 | //重定向到 37 | $this->redirect('@content/index',[],200,['ip'=>$ip,"port"=>$port,"auth"=>$auth]); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 void9main 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /thinkphp/library/think/exception/HttpResponseException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\Response; 15 | 16 | class HttpResponseException extends \RuntimeException 17 | { 18 | /** 19 | * @var Response 20 | */ 21 | protected $response; 22 | 23 | public function __construct(Response $response) 24 | { 25 | $this->response = $response; 26 | } 27 | 28 | public function getResponse() 29 | { 30 | return $this->response; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2016 Fabien Potencier 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /thinkphp/library/think/console/output/driver/Nothing.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\driver; 13 | 14 | use think\console\Output; 15 | 16 | class Nothing 17 | { 18 | 19 | public function __construct(Output $output) 20 | { 21 | // do nothing 22 | } 23 | 24 | public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL) 25 | { 26 | // do nothing 27 | } 28 | 29 | public function renderException(\Exception $e) 30 | { 31 | // do nothing 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /thinkphp/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: php 4 | 5 | services: 6 | - memcached 7 | - mongodb 8 | - mysql 9 | - postgresql 10 | - redis-server 11 | 12 | matrix: 13 | fast_finish: true 14 | include: 15 | - php: 5.4 16 | - php: 5.5 17 | - php: 5.6 18 | - php: 7.0 19 | - php: hhvm 20 | allow_failures: 21 | - php: hhvm 22 | 23 | cache: 24 | directories: 25 | - $HOME/.composer/cache 26 | 27 | before_install: 28 | - composer self-update 29 | - mysql -e "create database IF NOT EXISTS test;" -uroot 30 | - psql -c 'DROP DATABASE IF EXISTS test;' -U postgres 31 | - psql -c 'create database test;' -U postgres 32 | 33 | install: 34 | - ./tests/script/install.sh 35 | 36 | script: 37 | ## LINT 38 | - find . -path ./vendor -prune -o -type f -name \*.php -exec php -l {} \; 39 | ## PHP Copy/Paste Detector 40 | - vendor/bin/phpcpd --verbose --exclude vendor ./ || true 41 | ## PHPLOC 42 | - vendor/bin/phploc --exclude vendor ./ 43 | ## PHPUNIT 44 | - vendor/bin/phpunit --coverage-clover=coverage.xml --configuration=phpunit.xml 45 | 46 | after_success: 47 | - bash <(curl -s https://codecov.io/bash) 48 | -------------------------------------------------------------------------------- /vendor/composer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) Nils Adermann, Jordi Boggiano 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/ClassNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class ClassNotFoundException extends \RuntimeException 15 | { 16 | protected $class; 17 | public function __construct($message, $class = '') 18 | { 19 | $this->message = $message; 20 | $this->class = $class; 21 | } 22 | 23 | /** 24 | * 获取类名 25 | * @access public 26 | * @return string 27 | */ 28 | public function getClass() 29 | { 30 | return $this->class; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/TemplateNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class TemplateNotFoundException extends \RuntimeException 15 | { 16 | protected $template; 17 | 18 | public function __construct($message, $template = '') 19 | { 20 | $this->message = $message; 21 | $this->template = $template; 22 | } 23 | 24 | /** 25 | * 获取模板文件 26 | * @access public 27 | * @return string 28 | */ 29 | public function getTemplate() 30 | { 31 | return $this->template; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/ValidateException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class ValidateException extends \RuntimeException 15 | { 16 | protected $error; 17 | 18 | public function __construct($error) 19 | { 20 | $this->error = $error; 21 | $this->message = is_array($error) ? implode("\n\r", $error) : $error; 22 | } 23 | 24 | /** 25 | * 获取验证错误信息 26 | * @access public 27 | * @return array|string 28 | */ 29 | public function getError() 30 | { 31 | return $this->error; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /thinkphp/library/think/config/driver/Xml.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\config\driver; 13 | 14 | class Xml 15 | { 16 | public function parse($config) 17 | { 18 | if (is_file($config)) { 19 | $content = simplexml_load_file($config); 20 | } else { 21 | $content = simplexml_load_string($config); 22 | } 23 | $result = (array) $content; 24 | foreach ($result as $key => $val) { 25 | if (is_object($val)) { 26 | $result[$key] = (array) $val; 27 | } 28 | } 29 | return $result; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

SeeRedis

2 |

基于tp5.0框架开发的在线redis管理工具

3 |

环境配置

4 |

php版本大于5.5

5 |

php.ini配置了php_redis.dll扩展

6 |

7 | (备注)php_redis.dll扩展下载地址: 8 | http://pecl.php.net/package/redis 9 |

10 |

下载安装

11 |

git clone https://github.com/void9main/SeeRedis.git

12 |

使用方法

13 |

本地默认地址127.0.0.1,默认端口:6379

14 |

本地默认访问地址:127.0.0.1/seeredis/public/index.php

15 |

新增:密码设置,初始化密码位于config.php的password中,默认为123456

16 |

License

17 |

MIT

18 |

Copyright (c) 2019 void9main

19 |
20 |

Online redis management tool based on tp5.0 framework

21 |

Environment configuration

22 |

PHP version greater than 5.5

23 |

Php.ini is configured with the php_redis.dll extension

24 |

Install

25 |

git clone https://github.com/void9main/SeeRedis.git

26 |

Method of use

27 |

Local default address127.0.0.1,The default port:6379

28 |

Local default access address:127.0.0.1/seeredis/public/index.php

29 |

New: password Settings, the initialization password is in the password of config.php, the default is123456

30 |

License

31 |

MIT

32 |

Copyright (c) 2019 void9main

33 | -------------------------------------------------------------------------------- /application/index/view/action/delete.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/make/Model.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command\make; 13 | 14 | use think\console\command\Make; 15 | 16 | class Model extends Make 17 | { 18 | protected $type = "Model"; 19 | 20 | protected function configure() 21 | { 22 | parent::configure(); 23 | $this->setName('make:model') 24 | ->setDescription('Create a new model class'); 25 | } 26 | 27 | protected function getStub() 28 | { 29 | return __DIR__ . '/stubs/model.stub'; 30 | } 31 | 32 | protected function getNamespace($appNamespace, $module) 33 | { 34 | return parent::getNamespace($appNamespace, $module) . '\model'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /thinkphp/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests/thinkphp/ 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ./ 23 | 24 | tests 25 | vendor 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/exception/BindParamException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | /** 17 | * PDO参数绑定异常 18 | */ 19 | class BindParamException extends DbException 20 | { 21 | 22 | /** 23 | * BindParamException constructor. 24 | * @param string $message 25 | * @param array $config 26 | * @param string $sql 27 | * @param array $bind 28 | * @param int $code 29 | */ 30 | public function __construct($message, $config, $sql, $bind, $code = 10502) 31 | { 32 | $this->setData('Bind Param', $bind); 33 | parent::__construct($message, $config, $sql, $code); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/Expression.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db; 13 | 14 | class Expression 15 | { 16 | /** 17 | * 查询表达式 18 | * 19 | * @var string 20 | */ 21 | protected $value; 22 | 23 | /** 24 | * 创建一个查询表达式 25 | * 26 | * @param string $value 27 | * @return void 28 | */ 29 | public function __construct($value) 30 | { 31 | $this->value = $value; 32 | } 33 | 34 | /** 35 | * 获取表达式 36 | * 37 | * @return string 38 | */ 39 | public function getValue() 40 | { 41 | return $this->value; 42 | } 43 | 44 | public function __toString() 45 | { 46 | return (string) $this->value; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/HttpException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class HttpException extends \RuntimeException 15 | { 16 | private $statusCode; 17 | private $headers; 18 | 19 | public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = [], $code = 0) 20 | { 21 | $this->statusCode = $statusCode; 22 | $this->headers = $headers; 23 | 24 | parent::__construct($message, $code, $previous); 25 | } 26 | 27 | public function getStatusCode() 28 | { 29 | return $this->statusCode; 30 | } 31 | 32 | public function getHeaders() 33 | { 34 | return $this->headers; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /application/index/controller/Content.php: -------------------------------------------------------------------------------- 1 | info(); 22 | 23 | $dbinfoNum = Base::getleft($ip,$port,$auth); 24 | 25 | $this->assign('dbNum',$dbinfoNum); 26 | 27 | $infoArr = array_chunk($info,"23",true); 28 | 29 | Session::set("redis_address",json_encode(array("ip"=>$ip,"port"=>$port,"auth"=>$auth),true)); 30 | 31 | foreach($infoArr as $key=>$val){ 32 | $this->assign('dbInfo'.$key,$val); 33 | } 34 | 35 | $address = Session::get("redis_address"); 36 | 37 | if(!empty($address)){ 38 | 39 | $addArr = json_decode($address,true); 40 | 41 | $ip = $addArr['ip']; 42 | 43 | $port = $addArr['port']; 44 | 45 | }else{ 46 | 47 | $ip = "未知ip"; 48 | 49 | $port = "未知端口"; 50 | 51 | } 52 | 53 | $this->assign("ip",$ip); 54 | 55 | $this->assign("port",$port); 56 | 57 | return $this->fetch('index/content'); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /application/index/view/base/nav.html: -------------------------------------------------------------------------------- 1 |
2 | {php}if(!empty($actionName) and !empty($actionType)){{/php} 3 | {php}if($actionType == "success"){{/php} 4 | 7 | {php}}else if($actionType == "fail"){{/php} 8 | 11 | {php}}{/php} 12 | {php}}{/php} 13 |
14 | 25 | -------------------------------------------------------------------------------- /thinkphp/library/think/model/Pivot.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\model; 13 | 14 | use think\Model; 15 | 16 | class Pivot extends Model 17 | { 18 | 19 | /** @var Model */ 20 | public $parent; 21 | 22 | protected $autoWriteTimestamp = false; 23 | 24 | /** 25 | * 架构函数 26 | * @access public 27 | * @param array|object $data 数据 28 | * @param Model $parent 上级模型 29 | * @param string $table 中间数据表名 30 | */ 31 | public function __construct($data = [], Model $parent = null, $table = '') 32 | { 33 | $this->parent = $parent; 34 | 35 | if (is_null($this->name)) { 36 | $this->name = $table; 37 | } 38 | 39 | parent::__construct($data); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /thinkphp/library/think/Env.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | class Env 15 | { 16 | /** 17 | * 获取环境变量值 18 | * @access public 19 | * @param string $name 环境变量名(支持二级 . 号分割) 20 | * @param string $default 默认值 21 | * @return mixed 22 | */ 23 | public static function get($name, $default = null) 24 | { 25 | $result = getenv(ENV_PREFIX . strtoupper(str_replace('.', '_', $name))); 26 | 27 | if (false !== $result) { 28 | if ('false' === $result) { 29 | $result = false; 30 | } elseif ('true' === $result) { 31 | $result = true; 32 | } 33 | 34 | return $result; 35 | } 36 | 37 | return $default; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | 11 | array ( 12 | 'think\\composer\\' => 15, 13 | 'think\\' => 6, 14 | ), 15 | 'a' => 16 | array ( 17 | 'app\\' => 4, 18 | ), 19 | ); 20 | 21 | public static $prefixDirsPsr4 = array ( 22 | 'think\\composer\\' => 23 | array ( 24 | 0 => __DIR__ . '/..' . '/topthink/think-installer/src', 25 | ), 26 | 'think\\' => 27 | array ( 28 | 0 => __DIR__ . '/../..' . '/thinkphp/library/think', 29 | ), 30 | 'app\\' => 31 | array ( 32 | 0 => __DIR__ . '/../..' . '/application', 33 | ), 34 | ); 35 | 36 | public static function getInitializer(ClassLoader $loader) 37 | { 38 | return \Closure::bind(function () use ($loader) { 39 | $loader->prefixLengthsPsr4 = ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd::$prefixLengthsPsr4; 40 | $loader->prefixDirsPsr4 = ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd::$prefixDirsPsr4; 41 | 42 | }, null, ClassLoader::class); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /thinkphp/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 3 | 版权所有Copyright © 2006-2017 by ThinkPHP (http://thinkphp.cn) 4 | All rights reserved。 5 | ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 6 | 7 | Apache Licence是著名的非盈利开源组织Apache采用的协议。 8 | 该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, 9 | 允许代码修改,再作为开源或商业软件发布。需要满足 10 | 的条件: 11 | 1. 需要给代码的用户一份Apache Licence ; 12 | 2. 如果你修改了代码,需要在被修改的文件中说明; 13 | 3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 14 | 带有原来代码中的协议,商标,专利声明和其他原来作者规 15 | 定需要包含的说明; 16 | 4. 如果再发布的产品中包含一个Notice文件,则在Notice文 17 | 件中需要带有本协议内容。你可以在Notice中增加自己的 18 | 许可,但不可以表现为对Apache Licence构成更改。 19 | 具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/exception/ModelNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | class ModelNotFoundException extends DbException 17 | { 18 | protected $model; 19 | 20 | /** 21 | * 构造方法 22 | * @param string $message 23 | * @param string $model 24 | */ 25 | public function __construct($message, $model = '', array $config = []) 26 | { 27 | $this->message = $message; 28 | $this->model = $model; 29 | 30 | $this->setData('Database Config', $config); 31 | } 32 | 33 | /** 34 | * 获取模型类名 35 | * @access public 36 | * @return string 37 | */ 38 | public function getModel() 39 | { 40 | return $this->model; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /application/index/view/index/content.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {include file="base/header" /} 5 | 6 | 28 | 29 | {include file="base/nav" /} 30 | {include file="base/left" /} 31 |
32 |

Redis服务器信息:

33 |

redis-server:{$ip}:{$port}

34 |
35 | {volist name="dbInfo0" id="vo"} 36 |

{$key}:{$vo}

37 | {/volist} 38 |
39 |
40 | {volist name="dbInfo1" id="vo"} 41 |

{$key}:{$vo}

42 | {/volist} 43 |
44 |
45 | {volist name="dbInfo2" id="vo"} 46 |

{$key}:{$vo}

47 | {/volist} 48 |
49 |
50 | {volist name="dbInfo3" id="vo"} 51 |

{$key}:{$vo}

52 | {/volist} 53 |
54 |
55 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/exception/DataNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | class DataNotFoundException extends DbException 17 | { 18 | protected $table; 19 | 20 | /** 21 | * DbException constructor. 22 | * @param string $message 23 | * @param string $table 24 | * @param array $config 25 | */ 26 | public function __construct($message, $table = '', array $config = []) 27 | { 28 | $this->message = $message; 29 | $this->table = $table; 30 | 31 | $this->setData('Database Config', $config); 32 | } 33 | 34 | /** 35 | * 获取数据表名 36 | * @access public 37 | * @return string 38 | */ 39 | public function getTable() 40 | { 41 | return $this->table; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /application/index/view/action/timeset.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /application/index/view/action/addnew.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /application/index/view/base/page.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/DbException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\Exception; 15 | 16 | /** 17 | * Database相关异常处理类 18 | */ 19 | class DbException extends Exception 20 | { 21 | /** 22 | * DbException constructor. 23 | * @param string $message 24 | * @param array $config 25 | * @param string $sql 26 | * @param int $code 27 | */ 28 | public function __construct($message, array $config, $sql, $code = 10500) 29 | { 30 | $this->message = $message; 31 | $this->code = $code; 32 | 33 | $this->setData('Database Status', [ 34 | 'Error Code' => $code, 35 | 'Error Message' => $message, 36 | 'Error SQL' => $sql, 37 | ]); 38 | 39 | unset($config['username'], $config['password']); 40 | $this->setData('Database Config', $config); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /thinkphp/library/think/controller/Yar.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\controller; 13 | 14 | /** 15 | * ThinkPHP Yar控制器类 16 | */ 17 | abstract class Yar 18 | { 19 | 20 | /** 21 | * 构造函数 22 | * @access public 23 | */ 24 | public function __construct() 25 | { 26 | //控制器初始化 27 | if (method_exists($this, '_initialize')) { 28 | $this->_initialize(); 29 | } 30 | 31 | //判断扩展是否存在 32 | if (!extension_loaded('yar')) { 33 | throw new \Exception('not support yar'); 34 | } 35 | 36 | //实例化Yar_Server 37 | $server = new \Yar_Server($this); 38 | // 启动server 39 | $server->handle(); 40 | } 41 | 42 | /** 43 | * 魔术方法 有不存在的操作的时候执行 44 | * @access public 45 | * @param string $method 方法名 46 | * @param array $args 参数 47 | * @return mixed 48 | */ 49 | public function __call($method, $args) 50 | {} 51 | } 52 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/PDOException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | /** 15 | * PDO异常处理类 16 | * 重新封装了系统的\PDOException类 17 | */ 18 | class PDOException extends DbException 19 | { 20 | /** 21 | * PDOException constructor. 22 | * @param \PDOException $exception 23 | * @param array $config 24 | * @param string $sql 25 | * @param int $code 26 | */ 27 | public function __construct(\PDOException $exception, array $config, $sql, $code = 10501) 28 | { 29 | $error = $exception->errorInfo; 30 | 31 | $this->setData('PDO Error Info', [ 32 | 'SQLSTATE' => $error[0], 33 | 'Driver Error Code' => isset($error[1]) ? $error[1] : 0, 34 | 'Driver Error Message' => isset($error[2]) ? $error[2] : '', 35 | ]); 36 | 37 | parent::__construct($exception->getMessage(), $config, $sql, $code); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/output/driver/Buffer.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\driver; 13 | 14 | use think\console\Output; 15 | 16 | class Buffer 17 | { 18 | /** 19 | * @var string 20 | */ 21 | private $buffer = ''; 22 | 23 | public function __construct(Output $output) 24 | { 25 | // do nothing 26 | } 27 | 28 | public function fetch() 29 | { 30 | $content = $this->buffer; 31 | $this->buffer = ''; 32 | return $content; 33 | } 34 | 35 | public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL) 36 | { 37 | $messages = (array) $messages; 38 | 39 | foreach ($messages as $message) { 40 | $this->buffer .= $message; 41 | } 42 | if ($newline) { 43 | $this->buffer .= "\n"; 44 | } 45 | } 46 | 47 | public function renderException(\Exception $e) 48 | { 49 | // do nothing 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/make/stubs/controller.stub: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {include file="base/header" /} 5 | 6 | 7 |
8 |
9 |
10 |

SeeRedis在线管理工具

11 |
12 |
13 | 14 | 15 |
16 |
17 | 18 | 19 |
20 |
21 | 22 | 23 |
24 |
25 | 26 | 27 |
28 | 29 |
30 |
31 |
32 | -------------------------------------------------------------------------------- /thinkphp/library/think/process/exception/Failed.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\exception; 13 | 14 | use think\Process; 15 | 16 | class Failed extends \RuntimeException 17 | { 18 | 19 | private $process; 20 | 21 | public function __construct(Process $process) 22 | { 23 | if ($process->isSuccessful()) { 24 | throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.'); 25 | } 26 | 27 | $error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText()); 28 | 29 | if (!$process->isOutputDisabled()) { 30 | $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput()); 31 | } 32 | 33 | parent::__construct($error); 34 | 35 | $this->process = $process; 36 | } 37 | 38 | public function getProcess() 39 | { 40 | return $this->process; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /thinkphp/library/think/response/Json.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Response; 15 | 16 | class Json extends Response 17 | { 18 | // 输出参数 19 | protected $options = [ 20 | 'json_encode_param' => JSON_UNESCAPED_UNICODE, 21 | ]; 22 | 23 | protected $contentType = 'application/json'; 24 | 25 | /** 26 | * 处理数据 27 | * @access protected 28 | * @param mixed $data 要处理的数据 29 | * @return mixed 30 | * @throws \Exception 31 | */ 32 | protected function output($data) 33 | { 34 | try { 35 | // 返回JSON数据格式到客户端 包含状态信息 36 | $data = json_encode($data, $this->options['json_encode_param']); 37 | 38 | if ($data === false) { 39 | throw new \InvalidArgumentException(json_last_error_msg()); 40 | } 41 | 42 | return $data; 43 | } catch (\Exception $e) { 44 | if ($e->getPrevious()) { 45 | throw $e->getPrevious(); 46 | } 47 | throw $e; 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /thinkphp/library/think/Exception.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | class Exception extends \Exception 15 | { 16 | /** 17 | * @var array 保存异常页面显示的额外 Debug 数据 18 | */ 19 | protected $data = []; 20 | 21 | /** 22 | * 设置异常额外的 Debug 数据 23 | * 数据将会显示为下面的格式 24 | * 25 | * Exception Data 26 | * -------------------------------------------------- 27 | * Label 1 28 | * key1 value1 29 | * key2 value2 30 | * Label 2 31 | * key1 value1 32 | * key2 value2 33 | * 34 | * @access protected 35 | * @param string $label 数据分类,用于异常页面显示 36 | * @param array $data 需要显示的数据,必须为关联数组 37 | * @return void 38 | */ 39 | final protected function setData($label, array $data) 40 | { 41 | $this->data[$label] = $data; 42 | } 43 | 44 | /** 45 | * 获取异常额外 Debug 数据 46 | * 主要用于输出到异常页面便于调试 47 | * @access public 48 | * @return array 49 | */ 50 | final public function getData() 51 | { 52 | return $this->data; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/ThrowableError.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class ThrowableError extends \ErrorException 15 | { 16 | public function __construct(\Throwable $e) 17 | { 18 | 19 | if ($e instanceof \ParseError) { 20 | $message = 'Parse error: ' . $e->getMessage(); 21 | $severity = E_PARSE; 22 | } elseif ($e instanceof \TypeError) { 23 | $message = 'Type error: ' . $e->getMessage(); 24 | $severity = E_RECOVERABLE_ERROR; 25 | } else { 26 | $message = 'Fatal error: ' . $e->getMessage(); 27 | $severity = E_ERROR; 28 | } 29 | 30 | parent::__construct( 31 | $message, 32 | $e->getCode(), 33 | $severity, 34 | $e->getFile(), 35 | $e->getLine() 36 | ); 37 | 38 | $this->setTrace($e->getTrace()); 39 | } 40 | 41 | protected function setTrace($trace) 42 | { 43 | $traceReflector = new \ReflectionProperty('Exception', 'trace'); 44 | $traceReflector->setAccessible(true); 45 | $traceReflector->setValue($this, $trace); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /thinkphp/library/traits/think/Instance.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace traits\think; 13 | 14 | use think\Exception; 15 | 16 | trait Instance 17 | { 18 | /** 19 | * @var null|static 实例对象 20 | */ 21 | protected static $instance = null; 22 | 23 | /** 24 | * 获取示例 25 | * @param array $options 实例配置 26 | * @return static 27 | */ 28 | public static function instance($options = []) 29 | { 30 | if (is_null(self::$instance)) self::$instance = new self($options); 31 | 32 | return self::$instance; 33 | } 34 | 35 | /** 36 | * 静态调用 37 | * @param string $method 调用方法 38 | * @param array $params 调用参数 39 | * @return mixed 40 | * @throws Exception 41 | */ 42 | public static function __callStatic($method, array $params) 43 | { 44 | if (is_null(self::$instance)) self::$instance = new self(); 45 | 46 | $call = substr($method, 1); 47 | 48 | if (0 !== strpos($method, '_') || !is_callable([self::$instance, $call])) { 49 | throw new Exception("method not exists:" . $method); 50 | } 51 | 52 | return call_user_func_array([self::$instance, $call], $params); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /application/database.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | // 数据库类型 14 | 'type' => 'mysql', 15 | // 服务器地址 16 | 'hostname' => '127.0.0.1', 17 | // 数据库名 18 | 'database' => '', 19 | // 用户名 20 | 'username' => 'root', 21 | // 密码 22 | 'password' => '', 23 | // 端口 24 | 'hostport' => '', 25 | // 连接dsn 26 | 'dsn' => '', 27 | // 数据库连接参数 28 | 'params' => [], 29 | // 数据库编码默认采用utf8 30 | 'charset' => 'utf8', 31 | // 数据库表前缀 32 | 'prefix' => '', 33 | // 数据库调试模式 34 | 'debug' => true, 35 | // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 36 | 'deploy' => 0, 37 | // 数据库读写是否分离 主从式有效 38 | 'rw_separate' => false, 39 | // 读写分离后 主服务器数量 40 | 'master_num' => 1, 41 | // 指定从服务器序号 42 | 'slave_no' => '', 43 | // 自动读取主库数据 44 | 'read_master' => false, 45 | // 是否严格检查字段是否存在 46 | 'fields_strict' => true, 47 | // 数据集返回类型 48 | 'resultset_type' => 'array', 49 | // 自动写入时间戳字段 50 | 'auto_timestamp' => false, 51 | // 时间字段取出后的默认时间格式 52 | 'datetime_format' => 'Y-m-d H:i:s', 53 | // 是否需要进行SQL性能分析 54 | 'sql_explain' => false, 55 | ]; 56 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/make/Controller.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command\make; 13 | 14 | use think\Config; 15 | use think\console\command\Make; 16 | use think\console\input\Option; 17 | 18 | class Controller extends Make 19 | { 20 | 21 | protected $type = "Controller"; 22 | 23 | protected function configure() 24 | { 25 | parent::configure(); 26 | $this->setName('make:controller') 27 | ->addOption('plain', null, Option::VALUE_NONE, 'Generate an empty controller class.') 28 | ->setDescription('Create a new resource controller class'); 29 | } 30 | 31 | protected function getStub() 32 | { 33 | if ($this->input->getOption('plain')) { 34 | return __DIR__ . '/stubs/controller.plain.stub'; 35 | } 36 | 37 | return __DIR__ . '/stubs/controller.stub'; 38 | } 39 | 40 | protected function getClassName($name) 41 | { 42 | return parent::getClassName($name) . (Config::get('controller_suffix') ? ucfirst(Config::get('url_controller_layer')) : ''); 43 | } 44 | 45 | protected function getNamespace($appNamespace, $module) 46 | { 47 | return parent::getNamespace($appNamespace, $module) . '\controller'; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/ErrorException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\Exception; 15 | 16 | /** 17 | * ThinkPHP错误异常 18 | * 主要用于封装 set_error_handler 和 register_shutdown_function 得到的错误 19 | * 除开从 think\Exception 继承的功能 20 | * 其他和PHP系统\ErrorException功能基本一样 21 | */ 22 | class ErrorException extends Exception 23 | { 24 | /** 25 | * 用于保存错误级别 26 | * @var integer 27 | */ 28 | protected $severity; 29 | 30 | /** 31 | * 错误异常构造函数 32 | * @param integer $severity 错误级别 33 | * @param string $message 错误详细信息 34 | * @param string $file 出错文件路径 35 | * @param integer $line 出错行号 36 | * @param array $context 错误上下文,会包含错误触发处作用域内所有变量的数组 37 | */ 38 | public function __construct($severity, $message, $file, $line, array $context = []) 39 | { 40 | $this->severity = $severity; 41 | $this->message = $message; 42 | $this->file = $file; 43 | $this->line = $line; 44 | $this->code = 0; 45 | 46 | empty($context) || $this->setData('Error Context', $context); 47 | } 48 | 49 | /** 50 | * 获取错误级别 51 | * @return integer 错误级别 52 | */ 53 | final public function getSeverity() 54 | { 55 | return $this->severity; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/composer/autoload_real.php: -------------------------------------------------------------------------------- 1 | = 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 27 | if ($useStaticLoader) { 28 | require_once __DIR__ . '/autoload_static.php'; 29 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd::getInitializer($loader)); 31 | } else { 32 | $map = require __DIR__ . '/autoload_namespaces.php'; 33 | foreach ($map as $namespace => $path) { 34 | $loader->set($namespace, $path); 35 | } 36 | 37 | $map = require __DIR__ . '/autoload_psr4.php'; 38 | foreach ($map as $namespace => $path) { 39 | $loader->setPsr4($namespace, $path); 40 | } 41 | 42 | $classMap = require __DIR__ . '/autoload_classmap.php'; 43 | if ($classMap) { 44 | $loader->addClassMap($classMap); 45 | } 46 | } 47 | 48 | $loader->register(true); 49 | 50 | return $loader; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/output/question/Confirmation.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\question; 13 | 14 | use think\console\output\Question; 15 | 16 | class Confirmation extends Question 17 | { 18 | 19 | private $trueAnswerRegex; 20 | 21 | /** 22 | * 构造方法 23 | * @param string $question 问题 24 | * @param bool $default 默认答案 25 | * @param string $trueAnswerRegex 验证正则 26 | */ 27 | public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i') 28 | { 29 | parent::__construct($question, (bool) $default); 30 | 31 | $this->trueAnswerRegex = $trueAnswerRegex; 32 | $this->setNormalizer($this->getDefaultNormalizer()); 33 | } 34 | 35 | /** 36 | * 获取默认的答案回调 37 | * @return callable 38 | */ 39 | private function getDefaultNormalizer() 40 | { 41 | $default = $this->getDefault(); 42 | $regex = $this->trueAnswerRegex; 43 | 44 | return function ($answer) use ($default, $regex) { 45 | if (is_bool($answer)) { 46 | return $answer; 47 | } 48 | 49 | $answerIsTrue = (bool) preg_match($regex, $answer); 50 | if (false === $default) { 51 | return $answer && $answerIsTrue; 52 | } 53 | 54 | return !$answer || $answerIsTrue; 55 | }; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/Build.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\input\Option; 17 | use think\console\Output; 18 | 19 | class Build extends Command 20 | { 21 | 22 | /** 23 | * {@inheritdoc} 24 | */ 25 | protected function configure() 26 | { 27 | $this->setName('build') 28 | ->setDefinition([ 29 | new Option('config', null, Option::VALUE_OPTIONAL, "build.php path"), 30 | new Option('module', null, Option::VALUE_OPTIONAL, "module name"), 31 | ]) 32 | ->setDescription('Build Application Dirs'); 33 | } 34 | 35 | protected function execute(Input $input, Output $output) 36 | { 37 | if ($input->hasOption('module')) { 38 | \think\Build::module($input->getOption('module')); 39 | $output->writeln("Successed"); 40 | return; 41 | } 42 | 43 | if ($input->hasOption('config')) { 44 | $build = include $input->getOption('config'); 45 | } else { 46 | $build = include APP_PATH . 'build.php'; 47 | } 48 | if (empty($build)) { 49 | $output->writeln("Build Config Is Empty"); 50 | return; 51 | } 52 | \think\Build::run($build); 53 | $output->writeln("Successed"); 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /thinkphp/library/think/process/exception/Timeout.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\exception; 13 | 14 | use think\Process; 15 | 16 | class Timeout extends \RuntimeException 17 | { 18 | 19 | const TYPE_GENERAL = 1; 20 | const TYPE_IDLE = 2; 21 | 22 | private $process; 23 | private $timeoutType; 24 | 25 | public function __construct(Process $process, $timeoutType) 26 | { 27 | $this->process = $process; 28 | $this->timeoutType = $timeoutType; 29 | 30 | parent::__construct(sprintf('The process "%s" exceeded the timeout of %s seconds.', $process->getCommandLine(), $this->getExceededTimeout())); 31 | } 32 | 33 | public function getProcess() 34 | { 35 | return $this->process; 36 | } 37 | 38 | public function isGeneralTimeout() 39 | { 40 | return $this->timeoutType === self::TYPE_GENERAL; 41 | } 42 | 43 | public function isIdleTimeout() 44 | { 45 | return $this->timeoutType === self::TYPE_IDLE; 46 | } 47 | 48 | public function getExceededTimeout() 49 | { 50 | switch ($this->timeoutType) { 51 | case self::TYPE_GENERAL: 52 | return $this->process->getTimeout(); 53 | 54 | case self::TYPE_IDLE: 55 | return $this->process->getIdleTimeout(); 56 | 57 | default: 58 | throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType)); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/topthink/think-installer/src/ThinkFramework.php: -------------------------------------------------------------------------------- 1 | composer->getPackage()->getType() == 'project' && $package->getInstallationSource() != 'source') { 15 | //remove tests dir 16 | $this->filesystem->removeDirectory($this->getInstallPath($package) . DIRECTORY_SEPARATOR . 'tests'); 17 | } 18 | } 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | public function getInstallPath(PackageInterface $package) 24 | { 25 | if ('topthink/framework' !== $package->getPrettyName()) { 26 | throw new \InvalidArgumentException('Unable to install this library!'); 27 | } 28 | 29 | if ($this->composer->getPackage()->getType() !== 'project') { 30 | return parent::getInstallPath($package); 31 | } 32 | 33 | if ($this->composer->getPackage()) { 34 | $extra = $this->composer->getPackage()->getExtra(); 35 | if (!empty($extra['think-path'])) { 36 | return $extra['think-path']; 37 | } 38 | } 39 | 40 | return 'thinkphp'; 41 | } 42 | 43 | public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) 44 | { 45 | parent::update($repo, $initial, $target); 46 | if ($this->composer->getPackage()->getType() == 'project' && $target->getInstallationSource() != 'source') { 47 | //remove tests dir 48 | $this->filesystem->removeDirectory($this->getInstallPath($target) . DIRECTORY_SEPARATOR . 'tests'); 49 | } 50 | } 51 | 52 | /** 53 | * {@inheritDoc} 54 | */ 55 | public function supports($packageType) 56 | { 57 | return 'think-framework' === $packageType; 58 | } 59 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: php 4 | 5 | branches: 6 | only: 7 | - stable 8 | 9 | cache: 10 | directories: 11 | - $HOME/.composer/cache 12 | 13 | before_install: 14 | - composer self-update 15 | 16 | install: 17 | - composer install --no-dev --no-interaction --ignore-platform-reqs 18 | - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip . 19 | - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0" 20 | - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0" 21 | - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0" 22 | - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0" 23 | - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0" 24 | - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0" 25 | - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0" 26 | - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0" 27 | - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0" 28 | - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip . 29 | 30 | script: 31 | - php think unit 32 | 33 | deploy: 34 | provider: releases 35 | api_key: 36 | secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw= 37 | file: 38 | - ThinkPHP_Core.zip 39 | - ThinkPHP_Full.zip 40 | skip_cleanup: true 41 | on: 42 | tags: true 43 | -------------------------------------------------------------------------------- /thinkphp/library/think/response/Jsonp.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Request; 15 | use think\Response; 16 | 17 | class Jsonp extends Response 18 | { 19 | // 输出参数 20 | protected $options = [ 21 | 'var_jsonp_handler' => 'callback', 22 | 'default_jsonp_handler' => 'jsonpReturn', 23 | 'json_encode_param' => JSON_UNESCAPED_UNICODE, 24 | ]; 25 | 26 | protected $contentType = 'application/javascript'; 27 | 28 | /** 29 | * 处理数据 30 | * @access protected 31 | * @param mixed $data 要处理的数据 32 | * @return mixed 33 | * @throws \Exception 34 | */ 35 | protected function output($data) 36 | { 37 | try { 38 | // 返回JSON数据格式到客户端 包含状态信息 [当url_common_param为false时是无法获取到$_GET的数据的,故使用Request来获取] 39 | $var_jsonp_handler = Request::instance()->param($this->options['var_jsonp_handler'], ""); 40 | $handler = !empty($var_jsonp_handler) ? $var_jsonp_handler : $this->options['default_jsonp_handler']; 41 | 42 | $data = json_encode($data, $this->options['json_encode_param']); 43 | 44 | if ($data === false) { 45 | throw new \InvalidArgumentException(json_last_error_msg()); 46 | } 47 | 48 | $data = $handler . '(' . $data . ');'; 49 | return $data; 50 | } catch (\Exception $e) { 51 | if ($e->getPrevious()) { 52 | throw $e->getPrevious(); 53 | } 54 | throw $e; 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /application/index/controller/Base.php: -------------------------------------------------------------------------------- 1 | error("非法操作!",url('')); 22 | exit; 23 | } 24 | 25 | if(empty($name)){ 26 | $this->error("非法操作!",url('')); 27 | exit; 28 | } 29 | 30 | $dbinfoNum = self::getleft(); 31 | 32 | $this->dbinfoNum = $dbinfoNum; 33 | 34 | } 35 | 36 | 37 | private $redis_conn = ""; 38 | 39 | public static function getleft($ip="127.0.0.1",$port=6379,$auth = ""){ 40 | $redis = self::redis("0",$ip, $port,$auth); 41 | 42 | for($i=0;$i<17;$i++){ 43 | $redis->select($i); 44 | $dbinfo = $redis->keys("*"); 45 | $dbinfoNum[]['num'] = count($dbinfo); 46 | unset($dbinfo); 47 | } 48 | return $dbinfoNum; 49 | } 50 | 51 | public static function redis($db = "0",$ip="127.0.0.1",$port=6379,$auth = ""){ 52 | $redisInfo = Session::get("redis_address"); 53 | // 54 | if(!empty($redisInfo)){ 55 | $redisArr = json_decode($redisInfo,true); 56 | $ip = $redisArr['ip']; 57 | $port = $redisArr['port']; 58 | $auth = $redisArr['auth']; 59 | } 60 | try{ 61 | $redis = new \Redis(); 62 | }catch(\Exception $e){ 63 | throw new \Exception("php.ini缺少php_redis.dll文件配置"); 64 | } 65 | try{ 66 | $redis->connect($ip,$port); 67 | 68 | $redis->auth($auth); 69 | 70 | }catch(\Exception $e){ 71 | throw new \Exception("连接redis服务器失败,请检查redis服务器是否开启"); 72 | } 73 | 74 | $redis->select($db); 75 | 76 | return $redis; 77 | } 78 | 79 | public static function redis_conn($redis){ 80 | 81 | } 82 | 83 | public static function setActionType($row,$name){ 84 | 85 | Session::set("actionName",$name); 86 | 87 | if($row == "1"){ 88 | 89 | Session::set("actionType","success"); 90 | 91 | }else{ 92 | 93 | Session::set("actionType","fail"); 94 | 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/Clear.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | namespace think\console\command; 12 | 13 | use think\Cache; 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\input\Argument; 17 | use think\console\input\Option; 18 | use think\console\Output; 19 | 20 | class Clear extends Command 21 | { 22 | protected function configure() 23 | { 24 | // 指令配置 25 | $this 26 | ->setName('clear') 27 | ->addArgument('type', Argument::OPTIONAL, 'type to clear', null) 28 | ->addOption('path', 'd', Option::VALUE_OPTIONAL, 'path to clear', null) 29 | ->setDescription('Clear runtime file'); 30 | } 31 | 32 | protected function execute(Input $input, Output $output) 33 | { 34 | $path = $input->getOption('path') ?: RUNTIME_PATH; 35 | 36 | $type = $input->getArgument('type'); 37 | 38 | if ($type == 'route') { 39 | Cache::clear('route_check'); 40 | } else { 41 | if (is_dir($path)) { 42 | $this->clearPath($path); 43 | } 44 | } 45 | 46 | $output->writeln("Clear Successed"); 47 | } 48 | 49 | protected function clearPath($path) 50 | { 51 | $path = realpath($path) . DS; 52 | $files = scandir($path); 53 | if ($files) { 54 | foreach ($files as $file) { 55 | if ('.' != $file && '..' != $file && is_dir($path . $file)) { 56 | $this->clearPath($path . $file); 57 | } elseif ('.gitignore' != $file && is_file($path . $file)) { 58 | unlink($path . $file); 59 | } 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /thinkphp/tpl/dispatch_jump.tpl: -------------------------------------------------------------------------------- 1 | {__NOLAYOUT__} 2 | 3 | 4 | 5 | 6 | 跳转提示 7 | 17 | 18 | 19 |
20 | 21 | 22 |

:)

23 |

24 | 25 | 26 |

:(

27 |

28 | 29 | 30 |

31 |

32 | 页面自动 跳转 等待时间: 33 |

34 |
35 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /thinkphp/library/think/template/driver/File.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\template\driver; 13 | 14 | use think\Exception; 15 | 16 | class File 17 | { 18 | protected $cacheFile; 19 | 20 | /** 21 | * 写入编译缓存 22 | * @param string $cacheFile 缓存的文件名 23 | * @param string $content 缓存的内容 24 | * @return void|array 25 | */ 26 | public function write($cacheFile, $content) 27 | { 28 | // 检测模板目录 29 | $dir = dirname($cacheFile); 30 | if (!is_dir($dir)) { 31 | mkdir($dir, 0755, true); 32 | } 33 | // 生成模板缓存文件 34 | if (false === file_put_contents($cacheFile, $content)) { 35 | throw new Exception('cache write error:' . $cacheFile, 11602); 36 | } 37 | } 38 | 39 | /** 40 | * 读取编译编译 41 | * @param string $cacheFile 缓存的文件名 42 | * @param array $vars 变量数组 43 | * @return void 44 | */ 45 | public function read($cacheFile, $vars = []) 46 | { 47 | $this->cacheFile = $cacheFile; 48 | if (!empty($vars) && is_array($vars)) { 49 | // 模板阵列变量分解成为独立变量 50 | extract($vars, EXTR_OVERWRITE); 51 | } 52 | //载入模版缓存文件 53 | include $this->cacheFile; 54 | } 55 | 56 | /** 57 | * 检查编译缓存是否有效 58 | * @param string $cacheFile 缓存的文件名 59 | * @param int $cacheTime 缓存时间 60 | * @return boolean 61 | */ 62 | public function check($cacheFile, $cacheTime) 63 | { 64 | // 缓存文件不存在, 直接返回false 65 | if (!file_exists($cacheFile)) { 66 | return false; 67 | } 68 | if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > filemtime($cacheFile) + $cacheTime) { 69 | // 缓存是否在有效期 70 | return false; 71 | } 72 | return true; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /vendor/topthink/think-installer/src/ThinkTesting.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\composer; 13 | 14 | 15 | use Composer\Installer\LibraryInstaller; 16 | use Composer\Package\PackageInterface; 17 | use Composer\Repository\InstalledRepositoryInterface; 18 | 19 | class ThinkTesting extends LibraryInstaller 20 | { 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | public function getInstallPath(PackageInterface $package) 25 | { 26 | if ('topthink/think-testing' !== $package->getPrettyName()) { 27 | throw new \InvalidArgumentException('Unable to install this library!'); 28 | } 29 | 30 | return parent::getInstallPath($package); 31 | } 32 | 33 | public function install(InstalledRepositoryInterface $repo, PackageInterface $package) 34 | { 35 | parent::install($repo, $package); 36 | 37 | $this->copyTestDir($package); 38 | 39 | 40 | } 41 | 42 | public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) 43 | { 44 | parent::update($repo, $initial, $target); 45 | 46 | $this->copyTestDir($target); 47 | 48 | } 49 | 50 | private function copyTestDir(PackageInterface $package) 51 | { 52 | $appDir = dirname($this->vendorDir); 53 | $source = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . 'example'; 54 | if (!is_file($appDir . DIRECTORY_SEPARATOR . 'phpunit.xml')) { 55 | $this->filesystem->copyThenRemove($source, $appDir); 56 | } else { 57 | $this->filesystem->removeDirectoryPhp($source); 58 | } 59 | } 60 | 61 | /** 62 | * {@inheritDoc} 63 | */ 64 | public function supports($packageType) 65 | { 66 | return 'think-testing' === $packageType; 67 | } 68 | } -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/Help.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\input\Argument as InputArgument; 17 | use think\console\input\Option as InputOption; 18 | use think\console\Output; 19 | 20 | class Help extends Command 21 | { 22 | 23 | private $command; 24 | 25 | /** 26 | * {@inheritdoc} 27 | */ 28 | protected function configure() 29 | { 30 | $this->ignoreValidationErrors(); 31 | 32 | $this->setName('help')->setDefinition([ 33 | new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), 34 | new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), 35 | ])->setDescription('Displays help for a command')->setHelp(<<%command.name% command displays help for a given command: 37 | 38 | php %command.full_name% list 39 | 40 | To display the list of available commands, please use the list command. 41 | EOF 42 | ); 43 | } 44 | 45 | /** 46 | * Sets the command. 47 | * @param Command $command The command to set 48 | */ 49 | public function setCommand(Command $command) 50 | { 51 | $this->command = $command; 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | protected function execute(Input $input, Output $output) 58 | { 59 | if (null === $this->command) { 60 | $this->command = $this->getConsole()->find($input->getArgument('command_name')); 61 | } 62 | 63 | $output->describe($this->command, [ 64 | 'raw_text' => $input->getOption('raw'), 65 | ]); 66 | 67 | $this->command = null; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/Lists.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\Output; 17 | use think\console\input\Argument as InputArgument; 18 | use think\console\input\Option as InputOption; 19 | use think\console\input\Definition as InputDefinition; 20 | 21 | class Lists extends Command 22 | { 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | protected function configure() 28 | { 29 | $this->setName('list')->setDefinition($this->createDefinition())->setDescription('Lists commands')->setHelp(<<%command.name% command lists all commands: 31 | 32 | php %command.full_name% 33 | 34 | You can also display the commands for a specific namespace: 35 | 36 | php %command.full_name% test 37 | 38 | It's also possible to get raw list of commands (useful for embedding command runner): 39 | 40 | php %command.full_name% --raw 41 | EOF 42 | ); 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | */ 48 | public function getNativeDefinition() 49 | { 50 | return $this->createDefinition(); 51 | } 52 | 53 | /** 54 | * {@inheritdoc} 55 | */ 56 | protected function execute(Input $input, Output $output) 57 | { 58 | $output->describe($this->getConsole(), [ 59 | 'raw_text' => $input->getOption('raw'), 60 | 'namespace' => $input->getArgument('namespace'), 61 | ]); 62 | } 63 | 64 | /** 65 | * {@inheritdoc} 66 | */ 67 | private function createDefinition() 68 | { 69 | return new InputDefinition([ 70 | new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), 71 | new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list') 72 | ]); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/builder/Sqlite.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\builder; 13 | 14 | use think\db\Builder; 15 | 16 | /** 17 | * Sqlite数据库驱动 18 | */ 19 | class Sqlite extends Builder 20 | { 21 | 22 | /** 23 | * limit 24 | * @access public 25 | * @param string $limit 26 | * @return string 27 | */ 28 | public function parseLimit($limit) 29 | { 30 | $limitStr = ''; 31 | if (!empty($limit)) { 32 | $limit = explode(',', $limit); 33 | if (count($limit) > 1) { 34 | $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; 35 | } else { 36 | $limitStr .= ' LIMIT ' . $limit[0] . ' '; 37 | } 38 | } 39 | return $limitStr; 40 | } 41 | 42 | /** 43 | * 随机排序 44 | * @access protected 45 | * @return string 46 | */ 47 | protected function parseRand() 48 | { 49 | return 'RANDOM()'; 50 | } 51 | 52 | /** 53 | * 字段和表名处理 54 | * @access protected 55 | * @param mixed $key 56 | * @param array $options 57 | * @return string 58 | */ 59 | protected function parseKey($key, $options = [], $strict = false) 60 | { 61 | if (is_numeric($key)) { 62 | return $key; 63 | } elseif ($key instanceof Expression) { 64 | return $key->getValue(); 65 | } 66 | 67 | $key = trim($key); 68 | if (strpos($key, '.')) { 69 | list($table, $key) = explode('.', $key, 2); 70 | if ('__TABLE__' == $table) { 71 | $table = $this->query->getTable(); 72 | } 73 | if (isset($options['alias'][$table])) { 74 | $table = $options['alias'][$table]; 75 | } 76 | } 77 | if (isset($table)) { 78 | $key = $table . '.' . $key; 79 | } 80 | return $key; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /thinkphp/library/think/model/Collection.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\model; 13 | 14 | use think\Collection as BaseCollection; 15 | use think\Model; 16 | 17 | class Collection extends BaseCollection 18 | { 19 | /** 20 | * 延迟预载入关联查询 21 | * @access public 22 | * @param mixed $relation 关联 23 | * @return $this 24 | */ 25 | public function load($relation) 26 | { 27 | $item = current($this->items); 28 | $item->eagerlyResultSet($this->items, $relation); 29 | return $this; 30 | } 31 | 32 | /** 33 | * 设置需要隐藏的输出属性 34 | * @access public 35 | * @param array $hidden 属性列表 36 | * @param bool $override 是否覆盖 37 | * @return $this 38 | */ 39 | public function hidden($hidden = [], $override = false) 40 | { 41 | $this->each(function ($model) use ($hidden, $override) { 42 | /** @var Model $model */ 43 | $model->hidden($hidden, $override); 44 | }); 45 | return $this; 46 | } 47 | 48 | /** 49 | * 设置需要输出的属性 50 | * @param array $visible 51 | * @param bool $override 是否覆盖 52 | * @return $this 53 | */ 54 | public function visible($visible = [], $override = false) 55 | { 56 | $this->each(function ($model) use ($visible, $override) { 57 | /** @var Model $model */ 58 | $model->visible($visible, $override); 59 | }); 60 | return $this; 61 | } 62 | 63 | /** 64 | * 设置需要追加的输出属性 65 | * @access public 66 | * @param array $append 属性列表 67 | * @param bool $override 是否覆盖 68 | * @return $this 69 | */ 70 | public function append($append = [], $override = false) 71 | { 72 | $this->each(function ($model) use ($append, $override) { 73 | /** @var Model $model */ 74 | $model && $model->append($append, $override); 75 | }); 76 | return $this; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /thinkphp/library/think/process/Utils.php: -------------------------------------------------------------------------------- 1 | 8 | // +---------------------------------------------------------------------- 9 | 10 | namespace think\process; 11 | 12 | class Utils 13 | { 14 | 15 | /** 16 | * 转义字符串 17 | * @param string $argument 18 | * @return string 19 | */ 20 | public static function escapeArgument($argument) 21 | { 22 | 23 | if ('' === $argument) { 24 | return escapeshellarg($argument); 25 | } 26 | $escapedArgument = ''; 27 | $quote = false; 28 | foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { 29 | if ('"' === $part) { 30 | $escapedArgument .= '\\"'; 31 | } elseif (self::isSurroundedBy($part, '%')) { 32 | // Avoid environment variable expansion 33 | $escapedArgument .= '^%"' . substr($part, 1, -1) . '"^%'; 34 | } else { 35 | // escape trailing backslash 36 | if ('\\' === substr($part, -1)) { 37 | $part .= '\\'; 38 | } 39 | $quote = true; 40 | $escapedArgument .= $part; 41 | } 42 | } 43 | if ($quote) { 44 | $escapedArgument = '"' . $escapedArgument . '"'; 45 | } 46 | return $escapedArgument; 47 | } 48 | 49 | /** 50 | * 验证并进行规范化Process输入。 51 | * @param string $caller 52 | * @param mixed $input 53 | * @return string 54 | * @throws \InvalidArgumentException 55 | */ 56 | public static function validateInput($caller, $input) 57 | { 58 | if (null !== $input) { 59 | if (is_resource($input)) { 60 | return $input; 61 | } 62 | if (is_scalar($input)) { 63 | return (string) $input; 64 | } 65 | throw new \InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller)); 66 | } 67 | return $input; 68 | } 69 | 70 | private static function isSurroundedBy($arg, $char) 71 | { 72 | return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1]; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /thinkphp/library/think/process/pipes/Pipes.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\pipes; 13 | 14 | abstract class Pipes 15 | { 16 | 17 | /** @var array */ 18 | public $pipes = []; 19 | 20 | /** @var string */ 21 | protected $inputBuffer = ''; 22 | /** @var resource|null */ 23 | protected $input; 24 | 25 | /** @var bool */ 26 | private $blocked = true; 27 | 28 | const CHUNK_SIZE = 16384; 29 | 30 | /** 31 | * 返回用于 proc_open 描述符的数组 32 | * @return array 33 | */ 34 | abstract public function getDescriptors(); 35 | 36 | /** 37 | * 返回一个数组的索引由其相关的流,以防这些管道使用的临时文件的文件名。 38 | * @return string[] 39 | */ 40 | abstract public function getFiles(); 41 | 42 | /** 43 | * 文件句柄和管道中读取数据。 44 | * @param bool $blocking 是否使用阻塞调用 45 | * @param bool $close 是否要关闭管道,如果他们已经到达 EOF。 46 | * @return string[] 47 | */ 48 | abstract public function readAndWrite($blocking, $close = false); 49 | 50 | /** 51 | * 返回当前状态如果有打开的文件句柄或管道。 52 | * @return bool 53 | */ 54 | abstract public function areOpen(); 55 | 56 | /** 57 | * {@inheritdoc} 58 | */ 59 | public function close() 60 | { 61 | foreach ($this->pipes as $pipe) { 62 | fclose($pipe); 63 | } 64 | $this->pipes = []; 65 | } 66 | 67 | /** 68 | * 检查系统调用已被中断 69 | * @return bool 70 | */ 71 | protected function hasSystemCallBeenInterrupted() 72 | { 73 | $lastError = error_get_last(); 74 | 75 | return isset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call'); 76 | } 77 | 78 | protected function unblock() 79 | { 80 | if (!$this->blocked) { 81 | return; 82 | } 83 | 84 | foreach ($this->pipes as $pipe) { 85 | stream_set_blocking($pipe, 0); 86 | } 87 | if (null !== $this->input) { 88 | stream_set_blocking($this->input, 0); 89 | } 90 | 91 | $this->blocked = false; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /thinkphp/library/think/response/View.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Config; 15 | use think\Response; 16 | use think\View as ViewTemplate; 17 | 18 | class View extends Response 19 | { 20 | // 输出参数 21 | protected $options = []; 22 | protected $vars = []; 23 | protected $replace = []; 24 | protected $contentType = 'text/html'; 25 | 26 | /** 27 | * 处理数据 28 | * @access protected 29 | * @param mixed $data 要处理的数据 30 | * @return mixed 31 | */ 32 | protected function output($data) 33 | { 34 | // 渲染模板输出 35 | return ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str')) 36 | ->fetch($data, $this->vars, $this->replace); 37 | } 38 | 39 | /** 40 | * 获取视图变量 41 | * @access public 42 | * @param string $name 模板变量 43 | * @return mixed 44 | */ 45 | public function getVars($name = null) 46 | { 47 | if (is_null($name)) { 48 | return $this->vars; 49 | } else { 50 | return isset($this->vars[$name]) ? $this->vars[$name] : null; 51 | } 52 | } 53 | 54 | /** 55 | * 模板变量赋值 56 | * @access public 57 | * @param mixed $name 变量名 58 | * @param mixed $value 变量值 59 | * @return $this 60 | */ 61 | public function assign($name, $value = '') 62 | { 63 | if (is_array($name)) { 64 | $this->vars = array_merge($this->vars, $name); 65 | return $this; 66 | } else { 67 | $this->vars[$name] = $value; 68 | } 69 | return $this; 70 | } 71 | 72 | /** 73 | * 视图内容替换 74 | * @access public 75 | * @param string|array $content 被替换内容(支持批量替换) 76 | * @param string $replace 替换内容 77 | * @return $this 78 | */ 79 | public function replace($content, $replace = '') 80 | { 81 | if (is_array($content)) { 82 | $this->replace = array_merge($this->replace, $content); 83 | } else { 84 | $this->replace[$content] = $replace; 85 | } 86 | return $this; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /thinkphp/base.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | define('THINK_VERSION', '5.0.24'); 13 | define('THINK_START_TIME', microtime(true)); 14 | define('THINK_START_MEM', memory_get_usage()); 15 | define('EXT', '.php'); 16 | define('DS', DIRECTORY_SEPARATOR); 17 | defined('THINK_PATH') or define('THINK_PATH', __DIR__ . DS); 18 | define('LIB_PATH', THINK_PATH . 'library' . DS); 19 | define('CORE_PATH', LIB_PATH . 'think' . DS); 20 | define('TRAIT_PATH', LIB_PATH . 'traits' . DS); 21 | defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . DS); 22 | defined('ROOT_PATH') or define('ROOT_PATH', dirname(realpath(APP_PATH)) . DS); 23 | defined('EXTEND_PATH') or define('EXTEND_PATH', ROOT_PATH . 'extend' . DS); 24 | defined('VENDOR_PATH') or define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS); 25 | defined('RUNTIME_PATH') or define('RUNTIME_PATH', ROOT_PATH . 'runtime' . DS); 26 | defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH . 'log' . DS); 27 | defined('CACHE_PATH') or define('CACHE_PATH', RUNTIME_PATH . 'cache' . DS); 28 | defined('TEMP_PATH') or define('TEMP_PATH', RUNTIME_PATH . 'temp' . DS); 29 | defined('CONF_PATH') or define('CONF_PATH', APP_PATH); // 配置文件目录 30 | defined('CONF_EXT') or define('CONF_EXT', EXT); // 配置文件后缀 31 | defined('ENV_PREFIX') or define('ENV_PREFIX', 'PHP_'); // 环境变量的配置前缀 32 | 33 | // 环境常量 34 | define('IS_CLI', PHP_SAPI == 'cli' ? true : false); 35 | define('IS_WIN', strpos(PHP_OS, 'WIN') !== false); 36 | 37 | // 载入Loader类 38 | require CORE_PATH . 'Loader.php'; 39 | 40 | // 加载环境变量配置文件 41 | if (is_file(ROOT_PATH . '.env')) { 42 | $env = parse_ini_file(ROOT_PATH . '.env', true); 43 | 44 | foreach ($env as $key => $val) { 45 | $name = ENV_PREFIX . strtoupper($key); 46 | 47 | if (is_array($val)) { 48 | foreach ($val as $k => $v) { 49 | $item = $name . '_' . strtoupper($k); 50 | putenv("$item=$v"); 51 | } 52 | } else { 53 | putenv("$name=$val"); 54 | } 55 | } 56 | } 57 | 58 | // 注册自动加载 59 | \think\Loader::register(); 60 | 61 | // 注册错误和异常处理机制 62 | \think\Error::register(); 63 | 64 | // 加载惯例配置文件 65 | \think\Config::set(include THINK_PATH . 'convention' . EXT); 66 | -------------------------------------------------------------------------------- /application/index/view/db/dbindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {include file="base/header" /} 5 | 6 | 25 | 26 | {include file="base/nav" /} 27 | {include file="base/left" /} 28 |
29 |
30 |
31 | 32 | 33 | 34 | 35 |
36 |

db:{$db}  共{$allNum}条记录,共{php}echo ceil($allNum/15);{/php}页

37 |
38 |
39 |
40 | 46 | 49 | 50 |
51 |
52 |
53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | {volist name="keysPage" id="vo" key="k"} 61 | 62 | 63 | 64 | 65 | 82 | 83 | {/volist} 84 |
keytypetll操作
{$vo.name}{$vo.type}{$vo.ttl} 66 | {php}if($vo['ttl']!="unknow"){{/php} 67 | {include file="action/delete" /} 68 | 72 | {include file="action/select" /} 73 | 76 | {include file="action/timeset" /} 77 | 80 | {php}}{/php} 81 |
85 | {include file="base/page" /} 86 |
87 | 88 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/builder/Pgsql.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\builder; 13 | 14 | use think\db\Builder; 15 | 16 | /** 17 | * Pgsql数据库驱动 18 | */ 19 | class Pgsql extends Builder 20 | { 21 | protected $insertSql = 'INSERT INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; 22 | protected $insertAllSql = 'INSERT INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; 23 | 24 | /** 25 | * limit分析 26 | * @access protected 27 | * @param mixed $limit 28 | * @return string 29 | */ 30 | public function parseLimit($limit) 31 | { 32 | $limitStr = ''; 33 | if (!empty($limit)) { 34 | $limit = explode(',', $limit); 35 | if (count($limit) > 1) { 36 | $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; 37 | } else { 38 | $limitStr .= ' LIMIT ' . $limit[0] . ' '; 39 | } 40 | } 41 | return $limitStr; 42 | } 43 | 44 | /** 45 | * 字段和表名处理 46 | * @access protected 47 | * @param mixed $key 48 | * @param array $options 49 | * @return string 50 | */ 51 | protected function parseKey($key, $options = [], $strict = false) 52 | { 53 | if (is_numeric($key)) { 54 | return $key; 55 | } elseif ($key instanceof Expression) { 56 | return $key->getValue(); 57 | } 58 | 59 | $key = trim($key); 60 | if (strpos($key, '$.') && false === strpos($key, '(')) { 61 | // JSON字段支持 62 | list($field, $name) = explode('$.', $key); 63 | $key = $field . '->>\'' . $name . '\''; 64 | } elseif (strpos($key, '.')) { 65 | list($table, $key) = explode('.', $key, 2); 66 | if ('__TABLE__' == $table) { 67 | $table = $this->query->getTable(); 68 | } 69 | if (isset($options['alias'][$table])) { 70 | $table = $options['alias'][$table]; 71 | } 72 | } 73 | if (isset($table)) { 74 | $key = $table . '.' . $key; 75 | } 76 | return $key; 77 | } 78 | 79 | /** 80 | * 随机排序 81 | * @access protected 82 | * @return string 83 | */ 84 | protected function parseRand() 85 | { 86 | return 'RANDOM()'; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/optimize/Route.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | namespace think\console\command\optimize; 12 | 13 | use think\console\Command; 14 | use think\console\Input; 15 | use think\console\Output; 16 | 17 | class Route extends Command 18 | { 19 | /** @var Output */ 20 | protected $output; 21 | 22 | protected function configure() 23 | { 24 | $this->setName('optimize:route') 25 | ->setDescription('Build route cache.'); 26 | } 27 | 28 | protected function execute(Input $input, Output $output) 29 | { 30 | 31 | if (!is_dir(RUNTIME_PATH)) { 32 | @mkdir(RUNTIME_PATH, 0755, true); 33 | } 34 | 35 | file_put_contents(RUNTIME_PATH . 'route.php', $this->buildRouteCache()); 36 | $output->writeln('Succeed!'); 37 | } 38 | 39 | protected function buildRouteCache() 40 | { 41 | $files = \think\Config::get('route_config_file'); 42 | foreach ($files as $file) { 43 | if (is_file(CONF_PATH . $file . CONF_EXT)) { 44 | $config = include CONF_PATH . $file . CONF_EXT; 45 | if (is_array($config)) { 46 | \think\Route::import($config); 47 | } 48 | } 49 | } 50 | $rules = \think\Route::rules(true); 51 | array_walk_recursive($rules, [$this, 'buildClosure']); 52 | $content = 'getStartLine(); 63 | $endLine = $reflection->getEndLine(); 64 | $file = $reflection->getFileName(); 65 | $item = file($file); 66 | $content = ''; 67 | for ($i = $startLine - 1; $i <= $endLine - 1; $i++) { 68 | $content .= $item[$i]; 69 | } 70 | $start = strpos($content, 'function'); 71 | $end = strrpos($content, '}'); 72 | $value = '[__start__' . substr($content, $start, $end - $start + 1) . '__end__]'; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /vendor/topthink/think-installer/src/ThinkExtend.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\composer; 13 | 14 | use Composer\Installer\LibraryInstaller; 15 | use Composer\Package\PackageInterface; 16 | use Composer\Repository\InstalledRepositoryInterface; 17 | 18 | class ThinkExtend extends LibraryInstaller 19 | { 20 | 21 | public function install(InstalledRepositoryInterface $repo, PackageInterface $package) 22 | { 23 | parent::install($repo, $package); 24 | $this->copyExtraFiles($package); 25 | } 26 | 27 | public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) 28 | { 29 | parent::update($repo, $initial, $target); 30 | $this->copyExtraFiles($target); 31 | 32 | } 33 | 34 | protected function copyExtraFiles(PackageInterface $package) 35 | { 36 | if ($this->composer->getPackage()->getType() == 'project') { 37 | 38 | $extra = $package->getExtra(); 39 | 40 | if (!empty($extra['think-config'])) { 41 | 42 | $composerExtra = $this->composer->getPackage()->getExtra(); 43 | 44 | $appDir = !empty($composerExtra['app-path']) ? $composerExtra['app-path'] : 'application'; 45 | 46 | if (is_dir($appDir)) { 47 | 48 | $extraDir = $appDir . DIRECTORY_SEPARATOR . 'extra'; 49 | $this->filesystem->ensureDirectoryExists($extraDir); 50 | 51 | //配置文件 52 | foreach ((array) $extra['think-config'] as $name => $config) { 53 | $target = $extraDir . DIRECTORY_SEPARATOR . $name . '.php'; 54 | $source = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . $config; 55 | 56 | if (is_file($target)) { 57 | $this->io->write("File {$target} exist!"); 58 | continue; 59 | } 60 | 61 | if (!is_file($source)) { 62 | $this->io->write("File {$target} not exist!"); 63 | continue; 64 | } 65 | 66 | copy($source, $target); 67 | } 68 | } 69 | } 70 | } 71 | } 72 | 73 | public function supports($packageType) 74 | { 75 | return 'think-extend' === $packageType; 76 | } 77 | } -------------------------------------------------------------------------------- /thinkphp/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 如何贡献我的源代码 2 | === 3 | 4 | 此文档介绍了 ThinkPHP 团队的组成以及运转机制,您提交的代码将给 ThinkPHP 项目带来什么好处,以及如何才能加入我们的行列。 5 | 6 | ## 通过 Github 贡献代码 7 | 8 | ThinkPHP 目前使用 Git 来控制程序版本,如果你想为 ThinkPHP 贡献源代码,请先大致了解 Git 的使用方法。我们目前把项目托管在 GitHub 上,任何 GitHub 用户都可以向我们贡献代码。 9 | 10 | 参与的方式很简单,`fork`一份 ThinkPHP 的代码到你的仓库中,修改后提交,并向我们发起`pull request`申请,我们会及时对代码进行审查并处理你的申请。审查通过后,你的代码将被`merge`进我们的仓库中,这样你就会自动出现在贡献者名单里了,非常方便。 11 | 12 | 我们希望你贡献的代码符合: 13 | 14 | * ThinkPHP 的编码规范 15 | * 适当的注释,能让其他人读懂 16 | * 遵循 Apache2 开源协议 17 | 18 | **如果想要了解更多细节或有任何疑问,请继续阅读下面的内容** 19 | 20 | ### 注意事项 21 | 22 | * 本项目代码格式化标准选用 [**PSR-2**](http://www.kancloud.cn/thinkphp/php-fig-psr/3141); 23 | * 类名和类文件名遵循 [**PSR-4**](http://www.kancloud.cn/thinkphp/php-fig-psr/3144); 24 | * 对于 Issues 的处理,请使用诸如 `fix #xxx(Issue ID)` 的 commit title 直接关闭 issue。 25 | * 系统会自动在 PHP 5.4 5.5 5.6 7.0 和 HHVM 上测试修改,其中 HHVM 下的测试容许报错,请确保你的修改符合 PHP 5.4 ~ 5.6 和 PHP 7.0 的语法规范; 26 | * 管理员不会合并造成 CI faild 的修改,若出现 CI faild 请检查自己的源代码或修改相应的[单元测试文件](tests); 27 | 28 | ## GitHub Issue 29 | 30 | GitHub 提供了 Issue 功能,该功能可以用于: 31 | 32 | * 提出 bug 33 | * 提出功能改进 34 | * 反馈使用体验 35 | 36 | 该功能不应该用于: 37 | 38 | * 提出修改意见(涉及代码署名和修订追溯问题) 39 | * 不友善的言论 40 | 41 | ## 快速修改 42 | 43 | **GitHub 提供了快速编辑文件的功能** 44 | 45 | 1. 登录 GitHub 帐号; 46 | 2. 浏览项目文件,找到要进行修改的文件; 47 | 3. 点击右上角铅笔图标进行修改; 48 | 4. 填写 `Commit changes` 相关内容(Title 必填); 49 | 5. 提交修改,等待 CI 验证和管理员合并。 50 | 51 | **若您需要一次提交大量修改,请继续阅读下面的内容** 52 | 53 | ## 完整流程 54 | 55 | 1. `fork`本项目; 56 | 2. 克隆(`clone`)你 `fork` 的项目到本地; 57 | 3. 新建分支(`branch`)并检出(`checkout`)新分支; 58 | 4. 添加本项目到你的本地 git 仓库作为上游(`upstream`); 59 | 5. 进行修改,若你的修改包含方法或函数的增减,请记得修改[单元测试文件](tests); 60 | 6. 变基(衍合 `rebase`)你的分支到上游 master 分支; 61 | 7. `push` 你的本地仓库到 GitHub; 62 | 8. 提交 `pull request`; 63 | 9. 等待 CI 验证(若不通过则重复 5~7,不需要重新提交 `pull request`,GitHub 会自动更新你的 `pull request`); 64 | 10. 等待管理员处理,并及时 `rebase` 你的分支到上游 master 分支(若上游 master 分支有修改)。 65 | 66 | *若有必要,可以 `git push -f` 强行推送 rebase 后的分支到自己的 `fork`* 67 | 68 | *绝对不可以使用 `git push -f` 强行推送修改到上游* 69 | 70 | ### 注意事项 71 | 72 | * 若对上述流程有任何不清楚的地方,请查阅 GIT 教程,如 [这个](http://backlogtool.com/git-guide/cn/); 73 | * 对于代码**不同方面**的修改,请在自己 `fork` 的项目中**创建不同的分支**(原因参见`完整流程`第9条备注部分); 74 | * 变基及交互式变基操作参见 [Git 交互式变基](http://pakchoi.me/2015/03/17/git-interactive-rebase/) 75 | 76 | ## 推荐资源 77 | 78 | ### 开发环境 79 | 80 | * XAMPP for Windows 5.5.x 81 | * WampServer (for Windows) 82 | * upupw Apache PHP5.4 ( for Windows) 83 | 84 | 或自行安装 85 | 86 | - Apache / Nginx 87 | - PHP 5.4 ~ 5.6 88 | - MySQL / MariaDB 89 | 90 | *Windows 用户推荐添加 PHP bin 目录到 PATH,方便使用 composer* 91 | 92 | *Linux 用户自行配置环境, Mac 用户推荐使用内置 Apache 配合 Homebrew 安装 PHP 和 MariaDB* 93 | 94 | ### 编辑器 95 | 96 | Sublime Text 3 + phpfmt 插件 97 | 98 | phpfmt 插件参数 99 | 100 | ```json 101 | { 102 | "autocomplete": true, 103 | "enable_auto_align": true, 104 | "format_on_save": true, 105 | "indent_with_space": true, 106 | "psr1_naming": false, 107 | "psr2": true, 108 | "version": 4 109 | } 110 | ``` 111 | 112 | 或其他 编辑器 / IDE 配合 PSR2 自动格式化工具 113 | 114 | ### Git GUI 115 | 116 | * SourceTree 117 | * GitHub Desktop 118 | 119 | 或其他 Git 图形界面客户端 120 | -------------------------------------------------------------------------------- /thinkphp/library/think/response/Redirect.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Request; 15 | use think\Response; 16 | use think\Session; 17 | use think\Url; 18 | 19 | class Redirect extends Response 20 | { 21 | 22 | protected $options = []; 23 | 24 | // URL参数 25 | protected $params = []; 26 | 27 | public function __construct($data = '', $code = 302, array $header = [], array $options = []) 28 | { 29 | parent::__construct($data, $code, $header, $options); 30 | $this->cacheControl('no-cache,must-revalidate'); 31 | } 32 | 33 | /** 34 | * 处理数据 35 | * @access protected 36 | * @param mixed $data 要处理的数据 37 | * @return mixed 38 | */ 39 | protected function output($data) 40 | { 41 | $this->header['Location'] = $this->getTargetUrl(); 42 | return; 43 | } 44 | 45 | /** 46 | * 重定向传值(通过Session) 47 | * @access protected 48 | * @param string|array $name 变量名或者数组 49 | * @param mixed $value 值 50 | * @return $this 51 | */ 52 | public function with($name, $value = null) 53 | { 54 | if (is_array($name)) { 55 | foreach ($name as $key => $val) { 56 | Session::flash($key, $val); 57 | } 58 | } else { 59 | Session::flash($name, $value); 60 | } 61 | return $this; 62 | } 63 | 64 | /** 65 | * 获取跳转地址 66 | * @return string 67 | */ 68 | public function getTargetUrl() 69 | { 70 | if (strpos($this->data, '://') || (0 === strpos($this->data, '/') && empty($this->params))) { 71 | return $this->data; 72 | } else { 73 | return Url::build($this->data, $this->params); 74 | } 75 | } 76 | 77 | public function params($params = []) 78 | { 79 | $this->params = $params; 80 | return $this; 81 | } 82 | 83 | /** 84 | * 记住当前url后跳转 85 | * @return $this 86 | */ 87 | public function remember() 88 | { 89 | Session::set('redirect_url', Request::instance()->url()); 90 | return $this; 91 | } 92 | 93 | /** 94 | * 跳转到上次记住的url 95 | * @return $this 96 | */ 97 | public function restore() 98 | { 99 | if (Session::has('redirect_url')) { 100 | $this->data = Session::get('redirect_url'); 101 | Session::delete('redirect_url'); 102 | } 103 | return $this; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/output/formatter/Stack.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\formatter; 13 | 14 | class Stack 15 | { 16 | 17 | /** 18 | * @var Style[] 19 | */ 20 | private $styles; 21 | 22 | /** 23 | * @var Style 24 | */ 25 | private $emptyStyle; 26 | 27 | /** 28 | * 构造方法 29 | * @param Style|null $emptyStyle 30 | */ 31 | public function __construct(Style $emptyStyle = null) 32 | { 33 | $this->emptyStyle = $emptyStyle ?: new Style(); 34 | $this->reset(); 35 | } 36 | 37 | /** 38 | * 重置堆栈 39 | */ 40 | public function reset() 41 | { 42 | $this->styles = []; 43 | } 44 | 45 | /** 46 | * 推一个样式进入堆栈 47 | * @param Style $style 48 | */ 49 | public function push(Style $style) 50 | { 51 | $this->styles[] = $style; 52 | } 53 | 54 | /** 55 | * 从堆栈中弹出一个样式 56 | * @param Style|null $style 57 | * @return Style 58 | * @throws \InvalidArgumentException 59 | */ 60 | public function pop(Style $style = null) 61 | { 62 | if (empty($this->styles)) { 63 | return $this->emptyStyle; 64 | } 65 | 66 | if (null === $style) { 67 | return array_pop($this->styles); 68 | } 69 | 70 | /** 71 | * @var int $index 72 | * @var Style $stackedStyle 73 | */ 74 | foreach (array_reverse($this->styles, true) as $index => $stackedStyle) { 75 | if ($style->apply('') === $stackedStyle->apply('')) { 76 | $this->styles = array_slice($this->styles, 0, $index); 77 | 78 | return $stackedStyle; 79 | } 80 | } 81 | 82 | throw new \InvalidArgumentException('Incorrectly nested style tag found.'); 83 | } 84 | 85 | /** 86 | * 计算堆栈的当前样式。 87 | * @return Style 88 | */ 89 | public function getCurrent() 90 | { 91 | if (empty($this->styles)) { 92 | return $this->emptyStyle; 93 | } 94 | 95 | return $this->styles[count($this->styles) - 1]; 96 | } 97 | 98 | /** 99 | * @param Style $emptyStyle 100 | * @return Stack 101 | */ 102 | public function setEmptyStyle(Style $emptyStyle) 103 | { 104 | $this->emptyStyle = $emptyStyle; 105 | 106 | return $this; 107 | } 108 | 109 | /** 110 | * @return Style 111 | */ 112 | public function getEmptyStyle() 113 | { 114 | return $this->emptyStyle; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/connector/Sqlite.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\connector; 13 | 14 | use PDO; 15 | use think\db\Connection; 16 | 17 | /** 18 | * Sqlite数据库驱动 19 | */ 20 | class Sqlite extends Connection 21 | { 22 | 23 | protected $builder = '\\think\\db\\builder\\Sqlite'; 24 | 25 | /** 26 | * 解析pdo连接的dsn信息 27 | * @access protected 28 | * @param array $config 连接信息 29 | * @return string 30 | */ 31 | protected function parseDsn($config) 32 | { 33 | $dsn = 'sqlite:' . $config['database']; 34 | return $dsn; 35 | } 36 | 37 | /** 38 | * 取得数据表的字段信息 39 | * @access public 40 | * @param string $tableName 41 | * @return array 42 | */ 43 | public function getFields($tableName) 44 | { 45 | list($tableName) = explode(' ', $tableName); 46 | $sql = 'PRAGMA table_info( ' . $tableName . ' )'; 47 | 48 | $pdo = $this->query($sql, [], false, true); 49 | $result = $pdo->fetchAll(PDO::FETCH_ASSOC); 50 | $info = []; 51 | if ($result) { 52 | foreach ($result as $key => $val) { 53 | $val = array_change_key_case($val); 54 | $info[$val['name']] = [ 55 | 'name' => $val['name'], 56 | 'type' => $val['type'], 57 | 'notnull' => 1 === $val['notnull'], 58 | 'default' => $val['dflt_value'], 59 | 'primary' => '1' == $val['pk'], 60 | 'autoinc' => '1' == $val['pk'], 61 | ]; 62 | } 63 | } 64 | return $this->fieldCase($info); 65 | } 66 | 67 | /** 68 | * 取得数据库的表信息 69 | * @access public 70 | * @param string $dbName 71 | * @return array 72 | */ 73 | public function getTables($dbName = '') 74 | { 75 | 76 | $sql = "SELECT name FROM sqlite_master WHERE type='table' " 77 | . "UNION ALL SELECT name FROM sqlite_temp_master " 78 | . "WHERE type='table' ORDER BY name"; 79 | 80 | $pdo = $this->query($sql, [], false, true); 81 | $result = $pdo->fetchAll(PDO::FETCH_ASSOC); 82 | $info = []; 83 | foreach ($result as $key => $val) { 84 | $info[$key] = current($val); 85 | } 86 | return $info; 87 | } 88 | 89 | /** 90 | * SQL性能分析 91 | * @access protected 92 | * @param string $sql 93 | * @return array 94 | */ 95 | protected function getExplain($sql) 96 | { 97 | return []; 98 | } 99 | 100 | protected function supportSavepoint() 101 | { 102 | return true; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/input/Argument.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\input; 13 | 14 | class Argument 15 | { 16 | 17 | const REQUIRED = 1; 18 | const OPTIONAL = 2; 19 | const IS_ARRAY = 4; 20 | 21 | private $name; 22 | private $mode; 23 | private $default; 24 | private $description; 25 | 26 | /** 27 | * 构造方法 28 | * @param string $name 参数名 29 | * @param int $mode 参数类型: self::REQUIRED 或者 self::OPTIONAL 30 | * @param string $description 描述 31 | * @param mixed $default 默认值 (仅 self::OPTIONAL 类型有效) 32 | * @throws \InvalidArgumentException 33 | */ 34 | public function __construct($name, $mode = null, $description = '', $default = null) 35 | { 36 | if (null === $mode) { 37 | $mode = self::OPTIONAL; 38 | } elseif (!is_int($mode) || $mode > 7 || $mode < 1) { 39 | throw new \InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode)); 40 | } 41 | 42 | $this->name = $name; 43 | $this->mode = $mode; 44 | $this->description = $description; 45 | 46 | $this->setDefault($default); 47 | } 48 | 49 | /** 50 | * 获取参数名 51 | * @return string 52 | */ 53 | public function getName() 54 | { 55 | return $this->name; 56 | } 57 | 58 | /** 59 | * 是否必须 60 | * @return bool 61 | */ 62 | public function isRequired() 63 | { 64 | return self::REQUIRED === (self::REQUIRED & $this->mode); 65 | } 66 | 67 | /** 68 | * 该参数是否接受数组 69 | * @return bool 70 | */ 71 | public function isArray() 72 | { 73 | return self::IS_ARRAY === (self::IS_ARRAY & $this->mode); 74 | } 75 | 76 | /** 77 | * 设置默认值 78 | * @param mixed $default 默认值 79 | * @throws \LogicException 80 | */ 81 | public function setDefault($default = null) 82 | { 83 | if (self::REQUIRED === $this->mode && null !== $default) { 84 | throw new \LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.'); 85 | } 86 | 87 | if ($this->isArray()) { 88 | if (null === $default) { 89 | $default = []; 90 | } elseif (!is_array($default)) { 91 | throw new \LogicException('A default value for an array argument must be an array.'); 92 | } 93 | } 94 | 95 | $this->default = $default; 96 | } 97 | 98 | /** 99 | * 获取默认值 100 | * @return mixed 101 | */ 102 | public function getDefault() 103 | { 104 | return $this->default; 105 | } 106 | 107 | /** 108 | * 获取描述 109 | * @return string 110 | */ 111 | public function getDescription() 112 | { 113 | return $this->description; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /thinkphp/library/think/response/Xml.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Collection; 15 | use think\Model; 16 | use think\Response; 17 | 18 | class Xml extends Response 19 | { 20 | // 输出参数 21 | protected $options = [ 22 | // 根节点名 23 | 'root_node' => 'think', 24 | // 根节点属性 25 | 'root_attr' => '', 26 | //数字索引的子节点名 27 | 'item_node' => 'item', 28 | // 数字索引子节点key转换的属性名 29 | 'item_key' => 'id', 30 | // 数据编码 31 | 'encoding' => 'utf-8', 32 | ]; 33 | 34 | protected $contentType = 'text/xml'; 35 | 36 | /** 37 | * 处理数据 38 | * @access protected 39 | * @param mixed $data 要处理的数据 40 | * @return mixed 41 | */ 42 | protected function output($data) 43 | { 44 | // XML数据转换 45 | return $this->xmlEncode($data, $this->options['root_node'], $this->options['item_node'], $this->options['root_attr'], $this->options['item_key'], $this->options['encoding']); 46 | } 47 | 48 | /** 49 | * XML编码 50 | * @param mixed $data 数据 51 | * @param string $root 根节点名 52 | * @param string $item 数字索引的子节点名 53 | * @param string $attr 根节点属性 54 | * @param string $id 数字索引子节点key转换的属性名 55 | * @param string $encoding 数据编码 56 | * @return string 57 | */ 58 | protected function xmlEncode($data, $root, $item, $attr, $id, $encoding) 59 | { 60 | if (is_array($attr)) { 61 | $array = []; 62 | foreach ($attr as $key => $value) { 63 | $array[] = "{$key}=\"{$value}\""; 64 | } 65 | $attr = implode(' ', $array); 66 | } 67 | $attr = trim($attr); 68 | $attr = empty($attr) ? '' : " {$attr}"; 69 | $xml = ""; 70 | $xml .= "<{$root}{$attr}>"; 71 | $xml .= $this->dataToXml($data, $item, $id); 72 | $xml .= ""; 73 | return $xml; 74 | } 75 | 76 | /** 77 | * 数据XML编码 78 | * @param mixed $data 数据 79 | * @param string $item 数字索引时的节点名称 80 | * @param string $id 数字索引key转换为的属性名 81 | * @return string 82 | */ 83 | protected function dataToXml($data, $item, $id) 84 | { 85 | $xml = $attr = ''; 86 | 87 | if ($data instanceof Collection || $data instanceof Model) { 88 | $data = $data->toArray(); 89 | } 90 | 91 | foreach ($data as $key => $val) { 92 | if (is_numeric($key)) { 93 | $id && $attr = " {$id}=\"{$key}\""; 94 | $key = $item; 95 | } 96 | $xml .= "<{$key}{$attr}>"; 97 | $xml .= (is_array($val) || is_object($val)) ? $this->dataToXml($val, $item, $id) : $val; 98 | $xml .= ""; 99 | } 100 | return $xml; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/connector/Pgsql.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\connector; 13 | 14 | use PDO; 15 | use think\db\Connection; 16 | 17 | /** 18 | * Pgsql数据库驱动 19 | */ 20 | class Pgsql extends Connection 21 | { 22 | protected $builder = '\\think\\db\\builder\\Pgsql'; 23 | 24 | /** 25 | * 解析pdo连接的dsn信息 26 | * @access protected 27 | * @param array $config 连接信息 28 | * @return string 29 | */ 30 | protected function parseDsn($config) 31 | { 32 | $dsn = 'pgsql:dbname=' . $config['database'] . ';host=' . $config['hostname']; 33 | if (!empty($config['hostport'])) { 34 | $dsn .= ';port=' . $config['hostport']; 35 | } 36 | return $dsn; 37 | } 38 | 39 | /** 40 | * 取得数据表的字段信息 41 | * @access public 42 | * @param string $tableName 43 | * @return array 44 | */ 45 | public function getFields($tableName) 46 | { 47 | 48 | list($tableName) = explode(' ', $tableName); 49 | $sql = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg(\'' . $tableName . '\');'; 50 | 51 | $pdo = $this->query($sql, [], false, true); 52 | $result = $pdo->fetchAll(PDO::FETCH_ASSOC); 53 | $info = []; 54 | if ($result) { 55 | foreach ($result as $key => $val) { 56 | $val = array_change_key_case($val); 57 | $info[$val['field']] = [ 58 | 'name' => $val['field'], 59 | 'type' => $val['type'], 60 | 'notnull' => (bool) ('' !== $val['null']), 61 | 'default' => $val['default'], 62 | 'primary' => !empty($val['key']), 63 | 'autoinc' => (0 === strpos($val['extra'], 'nextval(')), 64 | ]; 65 | } 66 | } 67 | return $this->fieldCase($info); 68 | } 69 | 70 | /** 71 | * 取得数据库的表信息 72 | * @access public 73 | * @param string $dbName 74 | * @return array 75 | */ 76 | public function getTables($dbName = '') 77 | { 78 | $sql = "select tablename as Tables_in_test from pg_tables where schemaname ='public'"; 79 | $pdo = $this->query($sql, [], false, true); 80 | $result = $pdo->fetchAll(PDO::FETCH_ASSOC); 81 | $info = []; 82 | foreach ($result as $key => $val) { 83 | $info[$key] = current($val); 84 | } 85 | return $info; 86 | } 87 | 88 | /** 89 | * SQL性能分析 90 | * @access protected 91 | * @param string $sql 92 | * @return array 93 | */ 94 | protected function getExplain($sql) 95 | { 96 | return []; 97 | } 98 | 99 | protected function supportSavepoint() 100 | { 101 | return true; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/optimize/Config.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | namespace think\console\command\optimize; 12 | 13 | use think\Config as ThinkConfig; 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\input\Argument; 17 | use think\console\Output; 18 | 19 | class Config extends Command 20 | { 21 | /** @var Output */ 22 | protected $output; 23 | 24 | protected function configure() 25 | { 26 | $this->setName('optimize:config') 27 | ->addArgument('module', Argument::OPTIONAL, 'Build module config cache .') 28 | ->setDescription('Build config and common file cache.'); 29 | } 30 | 31 | protected function execute(Input $input, Output $output) 32 | { 33 | if ($input->getArgument('module')) { 34 | $module = $input->getArgument('module') . DS; 35 | } else { 36 | $module = ''; 37 | } 38 | 39 | $content = 'buildCacheContent($module); 40 | 41 | if (!is_dir(RUNTIME_PATH . $module)) { 42 | @mkdir(RUNTIME_PATH . $module, 0755, true); 43 | } 44 | 45 | file_put_contents(RUNTIME_PATH . $module . 'init' . EXT, $content); 46 | 47 | $output->writeln('Succeed!'); 48 | } 49 | 50 | protected function buildCacheContent($module) 51 | { 52 | $content = ''; 53 | $path = realpath(APP_PATH . $module) . DS; 54 | 55 | if ($module) { 56 | // 加载模块配置 57 | $config = ThinkConfig::load(CONF_PATH . $module . 'config' . CONF_EXT); 58 | 59 | // 读取数据库配置文件 60 | $filename = CONF_PATH . $module . 'database' . CONF_EXT; 61 | ThinkConfig::load($filename, 'database'); 62 | 63 | // 加载应用状态配置 64 | if ($config['app_status']) { 65 | $config = ThinkConfig::load(CONF_PATH . $module . $config['app_status'] . CONF_EXT); 66 | } 67 | // 读取扩展配置文件 68 | if (is_dir(CONF_PATH . $module . 'extra')) { 69 | $dir = CONF_PATH . $module . 'extra'; 70 | $files = scandir($dir); 71 | foreach ($files as $file) { 72 | if (strpos($file, CONF_EXT)) { 73 | $filename = $dir . DS . $file; 74 | ThinkConfig::load($filename, pathinfo($file, PATHINFO_FILENAME)); 75 | } 76 | } 77 | } 78 | } 79 | 80 | // 加载行为扩展文件 81 | if (is_file(CONF_PATH . $module . 'tags' . EXT)) { 82 | $content .= '\think\Hook::import(' . (var_export(include CONF_PATH . $module . 'tags' . EXT, true)) . ');' . PHP_EOL; 83 | } 84 | 85 | // 加载公共文件 86 | if (is_file($path . 'common' . EXT)) { 87 | $content .= substr(php_strip_whitespace($path . 'common' . EXT), 5) . PHP_EOL; 88 | } 89 | 90 | $content .= '\think\Config::set(' . var_export(ThinkConfig::get(), true) . ');'; 91 | return $content; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/Make.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\App; 15 | use think\Config; 16 | use think\console\Command; 17 | use think\console\Input; 18 | use think\console\input\Argument; 19 | use think\console\Output; 20 | 21 | abstract class Make extends Command 22 | { 23 | 24 | protected $type; 25 | 26 | abstract protected function getStub(); 27 | 28 | protected function configure() 29 | { 30 | $this->addArgument('name', Argument::REQUIRED, "The name of the class"); 31 | } 32 | 33 | protected function execute(Input $input, Output $output) 34 | { 35 | 36 | $name = trim($input->getArgument('name')); 37 | 38 | $classname = $this->getClassName($name); 39 | 40 | $pathname = $this->getPathName($classname); 41 | 42 | if (is_file($pathname)) { 43 | $output->writeln('' . $this->type . ' already exists!'); 44 | return false; 45 | } 46 | 47 | if (!is_dir(dirname($pathname))) { 48 | mkdir(strtolower(dirname($pathname)), 0755, true); 49 | } 50 | 51 | file_put_contents($pathname, $this->buildClass($classname)); 52 | 53 | $output->writeln('' . $this->type . ' created successfully.'); 54 | 55 | } 56 | 57 | protected function buildClass($name) 58 | { 59 | $stub = file_get_contents($this->getStub()); 60 | 61 | $namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\'); 62 | 63 | $class = str_replace($namespace . '\\', '', $name); 64 | 65 | return str_replace(['{%className%}', '{%namespace%}', '{%app_namespace%}'], [ 66 | $class, 67 | $namespace, 68 | App::$namespace, 69 | ], $stub); 70 | 71 | } 72 | 73 | protected function getPathName($name) 74 | { 75 | $name = str_replace(App::$namespace . '\\', '', $name); 76 | 77 | return APP_PATH . str_replace('\\', '/', $name) . '.php'; 78 | } 79 | 80 | protected function getClassName($name) 81 | { 82 | $appNamespace = App::$namespace; 83 | 84 | if (strpos($name, $appNamespace . '\\') === 0) { 85 | return $name; 86 | } 87 | 88 | if (Config::get('app_multi_module')) { 89 | if (strpos($name, '/')) { 90 | list($module, $name) = explode('/', $name, 2); 91 | } else { 92 | $module = 'common'; 93 | } 94 | } else { 95 | $module = null; 96 | } 97 | 98 | if (strpos($name, '/') !== false) { 99 | $name = str_replace('/', '\\', $name); 100 | } 101 | 102 | return $this->getNamespace($appNamespace, $module) . '\\' . $name; 103 | } 104 | 105 | protected function getNamespace($appNamespace, $module) 106 | { 107 | return $module ? ($appNamespace . '\\' . $module) : $appNamespace; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /thinkphp/library/think/controller/Rest.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\controller; 13 | 14 | use think\App; 15 | use think\Request; 16 | use think\Response; 17 | 18 | abstract class Rest 19 | { 20 | 21 | protected $method; // 当前请求类型 22 | protected $type; // 当前资源类型 23 | // 输出类型 24 | protected $restMethodList = 'get|post|put|delete'; 25 | protected $restDefaultMethod = 'get'; 26 | protected $restTypeList = 'html|xml|json|rss'; 27 | protected $restDefaultType = 'html'; 28 | protected $restOutputType = [ // REST允许输出的资源类型列表 29 | 'xml' => 'application/xml', 30 | 'json' => 'application/json', 31 | 'html' => 'text/html', 32 | ]; 33 | 34 | /** 35 | * 构造函数 取得模板对象实例 36 | * @access public 37 | */ 38 | public function __construct() 39 | { 40 | // 资源类型检测 41 | $request = Request::instance(); 42 | $ext = $request->ext(); 43 | if ('' == $ext) { 44 | // 自动检测资源类型 45 | $this->type = $request->type(); 46 | } elseif (!preg_match('/(' . $this->restTypeList . ')$/i', $ext)) { 47 | // 资源类型非法 则用默认资源类型访问 48 | $this->type = $this->restDefaultType; 49 | } else { 50 | $this->type = $ext; 51 | } 52 | // 请求方式检测 53 | $method = strtolower($request->method()); 54 | if (!preg_match('/(' . $this->restMethodList . ')$/i', $method)) { 55 | // 请求方式非法 则用默认请求方法 56 | $method = $this->restDefaultMethod; 57 | } 58 | $this->method = $method; 59 | } 60 | 61 | /** 62 | * REST 调用 63 | * @access public 64 | * @param string $method 方法名 65 | * @return mixed 66 | * @throws \Exception 67 | */ 68 | public function _empty($method) 69 | { 70 | if (method_exists($this, $method . '_' . $this->method . '_' . $this->type)) { 71 | // RESTFul方法支持 72 | $fun = $method . '_' . $this->method . '_' . $this->type; 73 | } elseif ($this->method == $this->restDefaultMethod && method_exists($this, $method . '_' . $this->type)) { 74 | $fun = $method . '_' . $this->type; 75 | } elseif ($this->type == $this->restDefaultType && method_exists($this, $method . '_' . $this->method)) { 76 | $fun = $method . '_' . $this->method; 77 | } 78 | if (isset($fun)) { 79 | return App::invokeMethod([$this, $fun]); 80 | } else { 81 | // 抛出异常 82 | throw new \Exception('error action :' . $method); 83 | } 84 | } 85 | 86 | /** 87 | * 输出返回数据 88 | * @access protected 89 | * @param mixed $data 要返回的数据 90 | * @param String $type 返回类型 JSON XML 91 | * @param integer $code HTTP状态码 92 | * @return Response 93 | */ 94 | protected function response($data, $type = 'json', $code = 200) 95 | { 96 | return Response::create($data, $type)->code($code); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /thinkphp/README.md: -------------------------------------------------------------------------------- 1 | ThinkPHP 5.0 2 | =============== 3 | 4 | [![StyleCI](https://styleci.io/repos/48530411/shield?style=flat&branch=master)](https://styleci.io/repos/48530411) 5 | [![Build Status](https://travis-ci.org/top-think/framework.svg?branch=master)](https://travis-ci.org/top-think/framework) 6 | [![codecov.io](http://codecov.io/github/top-think/framework/coverage.svg?branch=master)](http://codecov.io/github/github/top-think/framework?branch=master) 7 | [![Total Downloads](https://poser.pugx.org/topthink/framework/downloads)](https://packagist.org/packages/topthink/framework) 8 | [![Latest Stable Version](https://poser.pugx.org/topthink/framework/v/stable)](https://packagist.org/packages/topthink/framework) 9 | [![Latest Unstable Version](https://poser.pugx.org/topthink/framework/v/unstable)](https://packagist.org/packages/topthink/framework) 10 | [![License](https://poser.pugx.org/topthink/framework/license)](https://packagist.org/packages/topthink/framework) 11 | 12 | ThinkPHP5在保持快速开发和大道至简的核心理念不变的同时,PHP版本要求提升到5.4,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是ThinkPHP突破原有框架思路的颠覆之作,其主要特性包括: 13 | 14 | + 基于命名空间和众多PHP新特性 15 | + 核心功能组件化 16 | + 强化路由功能 17 | + 更灵活的控制器 18 | + 重构的模型和数据库类 19 | + 配置文件可分离 20 | + 重写的自动验证和完成 21 | + 简化扩展机制 22 | + API支持完善 23 | + 改进的Log类 24 | + 命令行访问支持 25 | + REST支持 26 | + 引导文件支持 27 | + 方便的自动生成定义 28 | + 真正惰性加载 29 | + 分布式环境支持 30 | + 支持Composer 31 | + 支持MongoDb 32 | 33 | > ThinkPHP5的运行环境要求PHP5.4以上。 34 | 35 | 详细开发文档参考 [ThinkPHP5完全开发手册](http://www.kancloud.cn/manual/thinkphp5) 以及[ThinkPHP5入门系列教程](http://www.kancloud.cn/special/thinkphp5_quickstart) 36 | 37 | ## 目录结构 38 | 39 | 初始的目录结构如下: 40 | 41 | ~~~ 42 | www WEB部署目录(或者子目录) 43 | ├─application 应用目录 44 | │ ├─common 公共模块目录(可以更改) 45 | │ ├─module_name 模块目录 46 | │ │ ├─config.php 模块配置文件 47 | │ │ ├─common.php 模块函数文件 48 | │ │ ├─controller 控制器目录 49 | │ │ ├─model 模型目录 50 | │ │ ├─view 视图目录 51 | │ │ └─ ... 更多类库目录 52 | │ │ 53 | │ ├─command.php 命令行工具配置文件 54 | │ ├─common.php 公共函数文件 55 | │ ├─config.php 公共配置文件 56 | │ ├─route.php 路由配置文件 57 | │ ├─tags.php 应用行为扩展定义文件 58 | │ └─database.php 数据库配置文件 59 | │ 60 | ├─public WEB目录(对外访问目录) 61 | │ ├─index.php 入口文件 62 | │ ├─router.php 快速测试文件 63 | │ └─.htaccess 用于apache的重写 64 | │ 65 | ├─thinkphp 框架系统目录 66 | │ ├─lang 语言文件目录 67 | │ ├─library 框架类库目录 68 | │ │ ├─think Think类库包目录 69 | │ │ └─traits 系统Trait目录 70 | │ │ 71 | │ ├─tpl 系统模板目录 72 | │ ├─base.php 基础定义文件 73 | │ ├─console.php 控制台入口文件 74 | │ ├─convention.php 框架惯例配置文件 75 | │ ├─helper.php 助手函数文件 76 | │ ├─phpunit.xml phpunit配置文件 77 | │ └─start.php 框架入口文件 78 | │ 79 | ├─extend 扩展类库目录 80 | ├─runtime 应用的运行时目录(可写,可定制) 81 | ├─vendor 第三方类库目录(Composer依赖库) 82 | ├─build.php 自动生成定义文件(参考) 83 | ├─composer.json composer 定义文件 84 | ├─LICENSE.txt 授权说明文件 85 | ├─README.md README 文件 86 | ├─think 命令行入口文件 87 | ~~~ 88 | 89 | > router.php用于php自带webserver支持,可用于快速测试 90 | > 切换到public目录后,启动命令:php -S localhost:8888 router.php 91 | > 上面的目录结构和名称是可以改变的,这取决于你的入口文件和配置参数。 92 | 93 | ## 命名规范 94 | 95 | ThinkPHP5的命名规范遵循`PSR-2`规范以及`PSR-4`自动加载规范。 96 | 97 | ## 参与开发 98 | 注册并登录 Github 帐号, fork 本项目并进行改动。 99 | 100 | 更多细节参阅 [CONTRIBUTING.md](CONTRIBUTING.md) 101 | 102 | ## 版权信息 103 | 104 | ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 105 | 106 | 本项目包含的第三方源码和二进制文件之版权信息另行标注。 107 | 108 | 版权所有Copyright © 2006-2018 by ThinkPHP (http://thinkphp.cn) 109 | 110 | All rights reserved。 111 | 112 | ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 113 | 114 | 更多细节参阅 [LICENSE.txt](LICENSE.txt) 115 | -------------------------------------------------------------------------------- /thinkphp/library/think/session/driver/Memcache.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\session\driver; 13 | 14 | use SessionHandler; 15 | use think\Exception; 16 | 17 | class Memcache extends SessionHandler 18 | { 19 | protected $handler = null; 20 | protected $config = [ 21 | 'host' => '127.0.0.1', // memcache主机 22 | 'port' => 11211, // memcache端口 23 | 'expire' => 3600, // session有效期 24 | 'timeout' => 0, // 连接超时时间(单位:毫秒) 25 | 'persistent' => true, // 长连接 26 | 'session_name' => '', // memcache key前缀 27 | ]; 28 | 29 | public function __construct($config = []) 30 | { 31 | $this->config = array_merge($this->config, $config); 32 | } 33 | 34 | /** 35 | * 打开Session 36 | * @access public 37 | * @param string $savePath 38 | * @param mixed $sessName 39 | */ 40 | public function open($savePath, $sessName) 41 | { 42 | // 检测php环境 43 | if (!extension_loaded('memcache')) { 44 | throw new Exception('not support:memcache'); 45 | } 46 | $this->handler = new \Memcache; 47 | // 支持集群 48 | $hosts = explode(',', $this->config['host']); 49 | $ports = explode(',', $this->config['port']); 50 | if (empty($ports[0])) { 51 | $ports[0] = 11211; 52 | } 53 | // 建立连接 54 | foreach ((array) $hosts as $i => $host) { 55 | $port = isset($ports[$i]) ? $ports[$i] : $ports[0]; 56 | $this->config['timeout'] > 0 ? 57 | $this->handler->addServer($host, $port, $this->config['persistent'], 1, $this->config['timeout']) : 58 | $this->handler->addServer($host, $port, $this->config['persistent'], 1); 59 | } 60 | return true; 61 | } 62 | 63 | /** 64 | * 关闭Session 65 | * @access public 66 | */ 67 | public function close() 68 | { 69 | $this->gc(ini_get('session.gc_maxlifetime')); 70 | $this->handler->close(); 71 | $this->handler = null; 72 | return true; 73 | } 74 | 75 | /** 76 | * 读取Session 77 | * @access public 78 | * @param string $sessID 79 | */ 80 | public function read($sessID) 81 | { 82 | return (string) $this->handler->get($this->config['session_name'] . $sessID); 83 | } 84 | 85 | /** 86 | * 写入Session 87 | * @access public 88 | * @param string $sessID 89 | * @param String $sessData 90 | * @return bool 91 | */ 92 | public function write($sessID, $sessData) 93 | { 94 | return $this->handler->set($this->config['session_name'] . $sessID, $sessData, 0, $this->config['expire']); 95 | } 96 | 97 | /** 98 | * 删除Session 99 | * @access public 100 | * @param string $sessID 101 | * @return bool 102 | */ 103 | public function destroy($sessID) 104 | { 105 | return $this->handler->delete($this->config['session_name'] . $sessID); 106 | } 107 | 108 | /** 109 | * Session 垃圾回收 110 | * @access public 111 | * @param string $sessMaxLifeTime 112 | * @return true 113 | */ 114 | public function gc($sessMaxLifeTime) 115 | { 116 | return true; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /vendor/composer/installed.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "topthink/framework", 4 | "version": "v5.0.21", 5 | "version_normalized": "5.0.21.0", 6 | "source": { 7 | "type": "git", 8 | "url": "https://github.com/top-think/framework.git", 9 | "reference": "ab826da071a7a47116a7f1d01f72228d6bcf212a" 10 | }, 11 | "dist": { 12 | "type": "zip", 13 | "url": "https://api.github.com/repos/top-think/framework/zipball/ab826da071a7a47116a7f1d01f72228d6bcf212a", 14 | "reference": "ab826da071a7a47116a7f1d01f72228d6bcf212a", 15 | "shasum": "", 16 | "mirrors": [ 17 | { 18 | "url": "https://dl.laravel-china.org/%package%/%reference%.%type%", 19 | "preferred": true 20 | } 21 | ] 22 | }, 23 | "require": { 24 | "php": ">=5.4.0", 25 | "topthink/think-installer": "~1.0" 26 | }, 27 | "require-dev": { 28 | "johnkary/phpunit-speedtrap": "^1.0", 29 | "mikey179/vfsstream": "~1.6", 30 | "phpdocumentor/reflection-docblock": "^2.0", 31 | "phploc/phploc": "2.*", 32 | "phpunit/phpunit": "4.8.*", 33 | "sebastian/phpcpd": "2.*" 34 | }, 35 | "time": "2018-09-04T09:18:48+00:00", 36 | "type": "think-framework", 37 | "installation-source": "dist", 38 | "autoload": { 39 | "psr-4": { 40 | "think\\": "library/think" 41 | } 42 | }, 43 | "notification-url": "https://packagist.org/downloads/", 44 | "license": [ 45 | "Apache-2.0" 46 | ], 47 | "authors": [ 48 | { 49 | "name": "liu21st", 50 | "email": "liu21st@gmail.com" 51 | } 52 | ], 53 | "description": "the new thinkphp framework", 54 | "homepage": "http://thinkphp.cn/", 55 | "keywords": [ 56 | "framework", 57 | "orm", 58 | "thinkphp" 59 | ] 60 | }, 61 | { 62 | "name": "topthink/think-installer", 63 | "version": "v1.0.12", 64 | "version_normalized": "1.0.12.0", 65 | "source": { 66 | "type": "git", 67 | "url": "https://github.com/top-think/think-installer.git", 68 | "reference": "1be326e68f63de4e95977ed50f46ae75f017556d" 69 | }, 70 | "dist": { 71 | "type": "zip", 72 | "url": "https://api.github.com/repos/top-think/think-installer/zipball/1be326e68f63de4e95977ed50f46ae75f017556d", 73 | "reference": "1be326e68f63de4e95977ed50f46ae75f017556d", 74 | "shasum": "", 75 | "mirrors": [ 76 | { 77 | "url": "https://dl.laravel-china.org/%package%/%reference%.%type%", 78 | "preferred": true 79 | } 80 | ] 81 | }, 82 | "require": { 83 | "composer-plugin-api": "^1.0" 84 | }, 85 | "require-dev": { 86 | "composer/composer": "1.0.*@dev" 87 | }, 88 | "time": "2017-05-27T06:58:09+00:00", 89 | "type": "composer-plugin", 90 | "extra": { 91 | "class": "think\\composer\\Plugin" 92 | }, 93 | "installation-source": "dist", 94 | "autoload": { 95 | "psr-4": { 96 | "think\\composer\\": "src" 97 | } 98 | }, 99 | "notification-url": "https://packagist.org/downloads/", 100 | "license": [ 101 | "Apache-2.0" 102 | ], 103 | "authors": [ 104 | { 105 | "name": "yunwuxin", 106 | "email": "448901948@qq.com" 107 | } 108 | ] 109 | } 110 | ] 111 | -------------------------------------------------------------------------------- /thinkphp/library/think/session/driver/Redis.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\session\driver; 13 | 14 | use SessionHandler; 15 | use think\Exception; 16 | 17 | class Redis extends SessionHandler 18 | { 19 | /** @var \Redis */ 20 | protected $handler = null; 21 | protected $config = [ 22 | 'host' => '127.0.0.1', // redis主机 23 | 'port' => 6379, // redis端口 24 | 'password' => '', // 密码 25 | 'select' => 0, // 操作库 26 | 'expire' => 3600, // 有效期(秒) 27 | 'timeout' => 0, // 超时时间(秒) 28 | 'persistent' => true, // 是否长连接 29 | 'session_name' => '', // sessionkey前缀 30 | ]; 31 | 32 | public function __construct($config = []) 33 | { 34 | $this->config = array_merge($this->config, $config); 35 | } 36 | 37 | /** 38 | * 打开Session 39 | * @access public 40 | * @param string $savePath 41 | * @param mixed $sessName 42 | * @return bool 43 | * @throws Exception 44 | */ 45 | public function open($savePath, $sessName) 46 | { 47 | // 检测php环境 48 | if (!extension_loaded('redis')) { 49 | throw new Exception('not support:redis'); 50 | } 51 | $this->handler = new \Redis; 52 | 53 | // 建立连接 54 | $func = $this->config['persistent'] ? 'pconnect' : 'connect'; 55 | $this->handler->$func($this->config['host'], $this->config['port'], $this->config['timeout']); 56 | 57 | if ('' != $this->config['password']) { 58 | $this->handler->auth($this->config['password']); 59 | } 60 | 61 | if (0 != $this->config['select']) { 62 | $this->handler->select($this->config['select']); 63 | } 64 | 65 | return true; 66 | } 67 | 68 | /** 69 | * 关闭Session 70 | * @access public 71 | */ 72 | public function close() 73 | { 74 | $this->gc(ini_get('session.gc_maxlifetime')); 75 | $this->handler->close(); 76 | $this->handler = null; 77 | return true; 78 | } 79 | 80 | /** 81 | * 读取Session 82 | * @access public 83 | * @param string $sessID 84 | * @return string 85 | */ 86 | public function read($sessID) 87 | { 88 | return (string) $this->handler->get($this->config['session_name'] . $sessID); 89 | } 90 | 91 | /** 92 | * 写入Session 93 | * @access public 94 | * @param string $sessID 95 | * @param String $sessData 96 | * @return bool 97 | */ 98 | public function write($sessID, $sessData) 99 | { 100 | if ($this->config['expire'] > 0) { 101 | return $this->handler->setex($this->config['session_name'] . $sessID, $this->config['expire'], $sessData); 102 | } else { 103 | return $this->handler->set($this->config['session_name'] . $sessID, $sessData); 104 | } 105 | } 106 | 107 | /** 108 | * 删除Session 109 | * @access public 110 | * @param string $sessID 111 | * @return bool 112 | */ 113 | public function destroy($sessID) 114 | { 115 | return $this->handler->delete($this->config['session_name'] . $sessID) > 0; 116 | } 117 | 118 | /** 119 | * Session 垃圾回收 120 | * @access public 121 | * @param string $sessMaxLifeTime 122 | * @return bool 123 | */ 124 | public function gc($sessMaxLifeTime) 125 | { 126 | return true; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /application/index/view/action/select.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /thinkphp/library/think/model/Relation.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\model; 13 | 14 | use think\db\Query; 15 | use think\Exception; 16 | use think\Model; 17 | 18 | /** 19 | * Class Relation 20 | * @package think\model 21 | * 22 | * @mixin Query 23 | */ 24 | abstract class Relation 25 | { 26 | // 父模型对象 27 | protected $parent; 28 | /** @var Model 当前关联的模型类 */ 29 | protected $model; 30 | /** @var Query 关联模型查询对象 */ 31 | protected $query; 32 | // 关联表外键 33 | protected $foreignKey; 34 | // 关联表主键 35 | protected $localKey; 36 | // 基础查询 37 | protected $baseQuery; 38 | // 是否为自关联 39 | protected $selfRelation; 40 | 41 | /** 42 | * 获取关联的所属模型 43 | * @access public 44 | * @return Model 45 | */ 46 | public function getParent() 47 | { 48 | return $this->parent; 49 | } 50 | 51 | /** 52 | * 获取当前的关联模型对象实例 53 | * @access public 54 | * @return Model 55 | */ 56 | public function getModel() 57 | { 58 | return $this->query->getModel(); 59 | } 60 | 61 | /** 62 | * 获取关联的查询对象 63 | * @access public 64 | * @return Query 65 | */ 66 | public function getQuery() 67 | { 68 | return $this->query; 69 | } 70 | 71 | /** 72 | * 设置当前关联为自关联 73 | * @access public 74 | * @param bool $self 是否自关联 75 | * @return $this 76 | */ 77 | public function selfRelation($self = true) 78 | { 79 | $this->selfRelation = $self; 80 | return $this; 81 | } 82 | 83 | /** 84 | * 当前关联是否为自关联 85 | * @access public 86 | * @return bool 87 | */ 88 | public function isSelfRelation() 89 | { 90 | return $this->selfRelation; 91 | } 92 | 93 | /** 94 | * 封装关联数据集 95 | * @access public 96 | * @param array $resultSet 数据集 97 | * @return mixed 98 | */ 99 | protected function resultSetBuild($resultSet) 100 | { 101 | return (new $this->model)->toCollection($resultSet); 102 | } 103 | 104 | protected function getQueryFields($model) 105 | { 106 | $fields = $this->query->getOptions('field'); 107 | return $this->getRelationQueryFields($fields, $model); 108 | } 109 | 110 | protected function getRelationQueryFields($fields, $model) 111 | { 112 | if ($fields) { 113 | 114 | if (is_string($fields)) { 115 | $fields = explode(',', $fields); 116 | } 117 | 118 | foreach ($fields as &$field) { 119 | if (false === strpos($field, '.')) { 120 | $field = $model . '.' . $field; 121 | } 122 | } 123 | } else { 124 | $fields = $model . '.*'; 125 | } 126 | 127 | return $fields; 128 | } 129 | 130 | /** 131 | * 执行基础查询(仅执行一次) 132 | * @access protected 133 | * @return void 134 | */ 135 | protected function baseQuery() 136 | {} 137 | 138 | public function __call($method, $args) 139 | { 140 | if ($this->query) { 141 | // 执行基础查询 142 | $this->baseQuery(); 143 | 144 | $result = call_user_func_array([$this->query, $method], $args); 145 | if ($result instanceof Query) { 146 | return $this; 147 | } else { 148 | $this->baseQuery = false; 149 | return $result; 150 | } 151 | } else { 152 | throw new Exception('method not exists:' . __CLASS__ . '->' . $method); 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /thinkphp/library/think/session/driver/Memcached.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\session\driver; 13 | 14 | use SessionHandler; 15 | use think\Exception; 16 | 17 | class Memcached extends SessionHandler 18 | { 19 | protected $handler = null; 20 | protected $config = [ 21 | 'host' => '127.0.0.1', // memcache主机 22 | 'port' => 11211, // memcache端口 23 | 'expire' => 3600, // session有效期 24 | 'timeout' => 0, // 连接超时时间(单位:毫秒) 25 | 'session_name' => '', // memcache key前缀 26 | 'username' => '', //账号 27 | 'password' => '', //密码 28 | ]; 29 | 30 | public function __construct($config = []) 31 | { 32 | $this->config = array_merge($this->config, $config); 33 | } 34 | 35 | /** 36 | * 打开Session 37 | * @access public 38 | * @param string $savePath 39 | * @param mixed $sessName 40 | */ 41 | public function open($savePath, $sessName) 42 | { 43 | // 检测php环境 44 | if (!extension_loaded('memcached')) { 45 | throw new Exception('not support:memcached'); 46 | } 47 | $this->handler = new \Memcached; 48 | // 设置连接超时时间(单位:毫秒) 49 | if ($this->config['timeout'] > 0) { 50 | $this->handler->setOption(\Memcached::OPT_CONNECT_TIMEOUT, $this->config['timeout']); 51 | } 52 | // 支持集群 53 | $hosts = explode(',', $this->config['host']); 54 | $ports = explode(',', $this->config['port']); 55 | if (empty($ports[0])) { 56 | $ports[0] = 11211; 57 | } 58 | // 建立连接 59 | $servers = []; 60 | foreach ((array) $hosts as $i => $host) { 61 | $servers[] = [$host, (isset($ports[$i]) ? $ports[$i] : $ports[0]), 1]; 62 | } 63 | $this->handler->addServers($servers); 64 | if ('' != $this->config['username']) { 65 | $this->handler->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); 66 | $this->handler->setSaslAuthData($this->config['username'], $this->config['password']); 67 | } 68 | return true; 69 | } 70 | 71 | /** 72 | * 关闭Session 73 | * @access public 74 | */ 75 | public function close() 76 | { 77 | $this->gc(ini_get('session.gc_maxlifetime')); 78 | $this->handler->quit(); 79 | $this->handler = null; 80 | return true; 81 | } 82 | 83 | /** 84 | * 读取Session 85 | * @access public 86 | * @param string $sessID 87 | */ 88 | public function read($sessID) 89 | { 90 | return (string) $this->handler->get($this->config['session_name'] . $sessID); 91 | } 92 | 93 | /** 94 | * 写入Session 95 | * @access public 96 | * @param string $sessID 97 | * @param String $sessData 98 | * @return bool 99 | */ 100 | public function write($sessID, $sessData) 101 | { 102 | return $this->handler->set($this->config['session_name'] . $sessID, $sessData, $this->config['expire']); 103 | } 104 | 105 | /** 106 | * 删除Session 107 | * @access public 108 | * @param string $sessID 109 | * @return bool 110 | */ 111 | public function destroy($sessID) 112 | { 113 | return $this->handler->delete($this->config['session_name'] . $sessID); 114 | } 115 | 116 | /** 117 | * Session 垃圾回收 118 | * @access public 119 | * @param string $sessMaxLifeTime 120 | * @return true 121 | */ 122 | public function gc($sessMaxLifeTime) 123 | { 124 | return true; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /thinkphp/library/think/Error.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | use think\console\Output as ConsoleOutput; 15 | use think\exception\ErrorException; 16 | use think\exception\Handle; 17 | use think\exception\ThrowableError; 18 | 19 | class Error 20 | { 21 | /** 22 | * 注册异常处理 23 | * @access public 24 | * @return void 25 | */ 26 | public static function register() 27 | { 28 | error_reporting(E_ALL); 29 | set_error_handler([__CLASS__, 'appError']); 30 | set_exception_handler([__CLASS__, 'appException']); 31 | register_shutdown_function([__CLASS__, 'appShutdown']); 32 | } 33 | 34 | /** 35 | * 异常处理 36 | * @access public 37 | * @param \Exception|\Throwable $e 异常 38 | * @return void 39 | */ 40 | public static function appException($e) 41 | { 42 | if (!$e instanceof \Exception) { 43 | $e = new ThrowableError($e); 44 | } 45 | 46 | $handler = self::getExceptionHandler(); 47 | $handler->report($e); 48 | 49 | if (IS_CLI) { 50 | $handler->renderForConsole(new ConsoleOutput, $e); 51 | } else { 52 | $handler->render($e)->send(); 53 | } 54 | } 55 | 56 | /** 57 | * 错误处理 58 | * @access public 59 | * @param integer $errno 错误编号 60 | * @param integer $errstr 详细错误信息 61 | * @param string $errfile 出错的文件 62 | * @param integer $errline 出错行号 63 | * @return void 64 | * @throws ErrorException 65 | */ 66 | public static function appError($errno, $errstr, $errfile = '', $errline = 0) 67 | { 68 | $exception = new ErrorException($errno, $errstr, $errfile, $errline); 69 | 70 | // 符合异常处理的则将错误信息托管至 think\exception\ErrorException 71 | if (error_reporting() & $errno) { 72 | throw $exception; 73 | } 74 | 75 | self::getExceptionHandler()->report($exception); 76 | } 77 | 78 | /** 79 | * 异常中止处理 80 | * @access public 81 | * @return void 82 | */ 83 | public static function appShutdown() 84 | { 85 | // 将错误信息托管至 think\ErrorException 86 | if (!is_null($error = error_get_last()) && self::isFatal($error['type'])) { 87 | self::appException(new ErrorException( 88 | $error['type'], $error['message'], $error['file'], $error['line'] 89 | )); 90 | } 91 | 92 | // 写入日志 93 | Log::save(); 94 | } 95 | 96 | /** 97 | * 确定错误类型是否致命 98 | * @access protected 99 | * @param int $type 错误类型 100 | * @return bool 101 | */ 102 | protected static function isFatal($type) 103 | { 104 | return in_array($type, [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE]); 105 | } 106 | 107 | /** 108 | * 获取异常处理的实例 109 | * @access public 110 | * @return Handle 111 | */ 112 | public static function getExceptionHandler() 113 | { 114 | static $handle; 115 | 116 | if (!$handle) { 117 | // 异常处理 handle 118 | $class = Config::get('exception_handle'); 119 | 120 | if ($class && is_string($class) && class_exists($class) && 121 | is_subclass_of($class, "\\think\\exception\\Handle") 122 | ) { 123 | $handle = new $class; 124 | } else { 125 | $handle = new Handle; 126 | 127 | if ($class instanceof \Closure) { 128 | $handle->setRender($class); 129 | } 130 | 131 | } 132 | } 133 | 134 | return $handle; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/connector/pgsql.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE FUNCTION pgsql_type(a_type varchar) RETURNS varchar AS 2 | $BODY$ 3 | DECLARE 4 | v_type varchar; 5 | BEGIN 6 | IF a_type='int8' THEN 7 | v_type:='bigint'; 8 | ELSIF a_type='int4' THEN 9 | v_type:='integer'; 10 | ELSIF a_type='int2' THEN 11 | v_type:='smallint'; 12 | ELSIF a_type='bpchar' THEN 13 | v_type:='char'; 14 | ELSE 15 | v_type:=a_type; 16 | END IF; 17 | RETURN v_type; 18 | END; 19 | $BODY$ 20 | LANGUAGE PLPGSQL; 21 | 22 | CREATE TYPE "public"."tablestruct" AS ( 23 | "fields_key_name" varchar(100), 24 | "fields_name" VARCHAR(200), 25 | "fields_type" VARCHAR(20), 26 | "fields_length" BIGINT, 27 | "fields_not_null" VARCHAR(10), 28 | "fields_default" VARCHAR(500), 29 | "fields_comment" VARCHAR(1000) 30 | ); 31 | 32 | CREATE OR REPLACE FUNCTION "public"."table_msg" (a_schema_name varchar, a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS 33 | $body$ 34 | DECLARE 35 | v_ret tablestruct; 36 | v_oid oid; 37 | v_sql varchar; 38 | v_rec RECORD; 39 | v_key varchar; 40 | BEGIN 41 | SELECT 42 | pg_class.oid INTO v_oid 43 | FROM 44 | pg_class 45 | INNER JOIN pg_namespace ON (pg_class.relnamespace = pg_namespace.oid AND lower(pg_namespace.nspname) = a_schema_name) 46 | WHERE 47 | pg_class.relname=a_table_name; 48 | IF NOT FOUND THEN 49 | RETURN; 50 | END IF; 51 | 52 | v_sql=' 53 | SELECT 54 | pg_attribute.attname AS fields_name, 55 | pg_attribute.attnum AS fields_index, 56 | pgsql_type(pg_type.typname::varchar) AS fields_type, 57 | pg_attribute.atttypmod-4 as fields_length, 58 | CASE WHEN pg_attribute.attnotnull THEN ''not null'' 59 | ELSE '''' 60 | END AS fields_not_null, 61 | pg_attrdef.adsrc AS fields_default, 62 | pg_description.description AS fields_comment 63 | FROM 64 | pg_attribute 65 | INNER JOIN pg_class ON pg_attribute.attrelid = pg_class.oid 66 | INNER JOIN pg_type ON pg_attribute.atttypid = pg_type.oid 67 | LEFT OUTER JOIN pg_attrdef ON pg_attrdef.adrelid = pg_class.oid AND pg_attrdef.adnum = pg_attribute.attnum 68 | LEFT OUTER JOIN pg_description ON pg_description.objoid = pg_class.oid AND pg_description.objsubid = pg_attribute.attnum 69 | WHERE 70 | pg_attribute.attnum > 0 71 | AND attisdropped <> ''t'' 72 | AND pg_class.oid = ' || v_oid || ' 73 | ORDER BY pg_attribute.attnum' ; 74 | 75 | FOR v_rec IN EXECUTE v_sql LOOP 76 | v_ret.fields_name=v_rec.fields_name; 77 | v_ret.fields_type=v_rec.fields_type; 78 | IF v_rec.fields_length > 0 THEN 79 | v_ret.fields_length:=v_rec.fields_length; 80 | ELSE 81 | v_ret.fields_length:=NULL; 82 | END IF; 83 | v_ret.fields_not_null=v_rec.fields_not_null; 84 | v_ret.fields_default=v_rec.fields_default; 85 | v_ret.fields_comment=v_rec.fields_comment; 86 | SELECT constraint_name INTO v_key FROM information_schema.key_column_usage WHERE table_schema=a_schema_name AND table_name=a_table_name AND column_name=v_rec.fields_name; 87 | IF FOUND THEN 88 | v_ret.fields_key_name=v_key; 89 | ELSE 90 | v_ret.fields_key_name=''; 91 | END IF; 92 | RETURN NEXT v_ret; 93 | END LOOP; 94 | RETURN ; 95 | END; 96 | $body$ 97 | LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; 98 | 99 | COMMENT ON FUNCTION "public"."table_msg"(a_schema_name varchar, a_table_name varchar) 100 | IS '获得表信息'; 101 | 102 | ---重载一个函数 103 | CREATE OR REPLACE FUNCTION "public"."table_msg" (a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS 104 | $body$ 105 | DECLARE 106 | v_ret tablestruct; 107 | BEGIN 108 | FOR v_ret IN SELECT * FROM table_msg('public',a_table_name) LOOP 109 | RETURN NEXT v_ret; 110 | END LOOP; 111 | RETURN; 112 | END; 113 | $body$ 114 | LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; 115 | 116 | COMMENT ON FUNCTION "public"."table_msg"(a_table_name varchar) 117 | IS '获得表信息'; --------------------------------------------------------------------------------