├── .example_env ├── .gitignore ├── LICENSE.txt ├── README.md ├── Socket_server.php ├── application ├── .htaccess ├── addons │ └── cache │ │ ├── Common.php │ │ ├── hook │ │ ├── CacheChartInfo.php │ │ ├── ChartProcess.php │ │ └── Chartdata.php │ │ └── model │ │ ├── Datament.php │ │ ├── Screenchart.php │ │ └── Screencharttconfig.php ├── base │ └── controller │ │ ├── Addons.php │ │ └── Base.php ├── command.php ├── common.php ├── config.php ├── database.php ├── extra │ ├── addons.php │ ├── chartType.php │ └── queue.php ├── index │ ├── common.php │ ├── controller │ │ ├── Audit.php │ │ ├── Backdown.php │ │ ├── Carousel.php │ │ ├── Chart.php │ │ ├── Databasesource.php │ │ ├── Datamap.php │ │ ├── Datament.php │ │ ├── Datasource.php │ │ ├── Deviceinfo.php │ │ ├── Drilldown.php │ │ ├── File.php │ │ ├── Icon.php │ │ ├── Index.php │ │ ├── My.php │ │ ├── Page.php │ │ ├── Releasebinding.php │ │ ├── Rep.php │ │ ├── Screen.php │ │ ├── Setsystem.php │ │ ├── Socket.php │ │ ├── Socketscreen.php │ │ ├── System.php │ │ ├── Template.php │ │ ├── Template1.php │ │ ├── Test.php │ │ ├── Unity.php │ │ ├── User.php │ │ ├── Viewdata.php │ │ ├── Websocket.php │ │ ├── Windex.php │ │ └── Woperating.php │ └── model │ │ ├── Carousel.php │ │ ├── Deviceinfo.php │ │ ├── Gisdata.php │ │ ├── My.php │ │ ├── Publish.php │ │ ├── Screen.php │ │ ├── Screenchart.php │ │ ├── Unity.php │ │ ├── Unityjson.php │ │ ├── User.php │ │ └── sdata.php ├── plugins │ ├── common.php │ ├── controller │ │ ├── Demo.php │ │ ├── Index.php │ │ └── Upload.php │ └── model │ │ ├── FileUtil.php │ │ └── Plugins.php ├── release │ ├── config.php │ └── controller │ │ └── Index.php ├── route.php ├── tags.php ├── user │ ├── controller │ │ └── User.php │ └── model │ │ └── User.php └── websocket │ └── controller │ └── Setting.php ├── build.php ├── composer.json ├── composer.lock ├── data └── .gitignore ├── doc ├── FAQ.md └── plugin.md ├── docker-compose.yml ├── docker ├── Dockerfile ├── default.conf ├── fpm.service ├── nginx.conf ├── nginx.service └── php.ini ├── extend ├── DataSource.php └── datasource │ ├── Currency.php │ ├── Elasticsearch.php │ ├── Mongo.php │ └── Oracle.php ├── openbi.sql ├── public ├── .htaccess ├── CommonPlugins │ ├── echarts4.8 │ │ └── echarts.min.js │ ├── echarts5.0 │ │ └── echarts.min.js │ └── jquery3.5 │ │ └── jquery.min.js ├── ConvertIpNew.php ├── Cover │ └── .gitignore ├── KindEditor │ ├── JSON.php │ ├── attached │ │ └── 1.php │ └── upload_json.php ├── alg │ └── .gitignore ├── api.php ├── index.php ├── robots.txt ├── router.php ├── static │ ├── css │ │ └── wd.css │ ├── img │ │ ├── Oval.png │ │ ├── logo.png │ │ └── medical.png │ └── js │ │ └── my.js └── uploads │ ├── logo │ └── defualt │ │ └── logo.png │ └── staticimg │ ├── perview_avatar_1.png │ ├── perview_avatar_2.png │ └── perview_avatar_3.png ├── runtime └── .gitignore ├── think └── vendor └── .gitignore /.example_env: -------------------------------------------------------------------------------- 1 | [config] 2 | app_debug = true 3 | app_trace = true 4 | static_config_path = public/openv/static/config.json 5 | [database] 6 | hostname = 127.0.0.1 7 | database = openbi 8 | username = root 9 | password = 123456 10 | hostport = 3306 11 | charset = utf8mb4 12 | prefix = up_ 13 | debug = false 14 | [redis] 15 | host = 127.0.0.1 16 | port = 6379 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.log 3 | favicon.ico 4 | thinkphp 5 | openv 6 | .env 7 | .DS_Store 8 | .vscode 9 | thinkphp 10 | framework 11 | tests/ 12 | public/uploads -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | OpenBI 数据可视化软件,支持的是NC协议。 2 | 可以进行个人使用,但是不可以进行商业使用。 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 官方地址 2 | 3 | [http://www.openbi.com.cn/](http://www.openbi.com.cn/) 4 | 5 | ## 安装方式一 6 | 7 | - 环境要求PHP7.0以上。(建议PHP7.2) 8 | 9 | - 建议环境 lnmp 10 | 11 | - 从 [releases](https://github.com/openBI-kwc/openBI/releases/) 下载部署包openbi.zip 12 | 13 | - 将openbi.zip 上传到服务器并解压到指定位置 14 | 15 | - 将解压的目录授权到web服务启动用户(如: chown -R www:www /home/wwwroot/openbi) 16 | 17 | - 配置 nginx server模块新增webserver的ip或域名与openbi的路径绑定 18 | 19 | - 部署不支持二级目录,请直接将域名或ip定位到项目目录/public下 20 | 21 | - 添加重写规则 22 | 23 | ```bash 24 | if (!-e $request_filename) { 25 | rewrite ^(.*)$ /index.php?s=$1 last; 26 | break; 27 | } 28 | ``` 29 | 30 | - 进入到openbi解压目录 找到.example_env 并复制为 .env (linux执行:cp .example_env .env) 31 | 32 | - 导入openbi.sql 33 | 34 | - 修改 .env 相应配置(配置数据库信息) 35 | 36 | - 默认账号密码 admin / admin 37 | 38 | - 请取消禁用函数 putenv (php.ini中disable_function) 39 | 40 | ## 安装方式二 41 | 42 | - 使用宝塔面板一键部署安装 43 | 44 | ## 安装方式三 45 | 46 | - 从 [releases](https://github.com/openBI-kwc/openBI/releases/) 下载部署包openbi.zip (适用于**版本1.0.5**及以上) 47 | 48 | - 解压 49 | 50 | - 安装docker,docker-compose后运行 51 | 52 | ```bash 53 | docker-compose up 54 | # 后台运行 55 | docker-compose up -d 56 | ``` 57 | 58 | - 注意默认端口为80、3306、6379、若有端口占用,请修改docker-compoe.yml相关端口 59 | 60 | - 默认数据库mysql的密码为root 61 | 62 | - 将openbi.sql导入数据库 63 | 64 | - 进入到openbi解压目录 找到.example_env 并复制为 .env 65 | 66 | - 修改 .env 相关数据库配置 67 | 68 | - 默认访问地址:[ip:80]() 账号密码(默认账号密码 admin / admin) 69 | 70 | ## 其他文档 71 | 72 | - FAQ [doc/FAQ.md](doc/FAQ.md) 73 | 74 | - 插件开发[doc/plugin.md](doc/plugin.md) 75 | 76 | ## 数据源支持 77 | 78 | - excel/csv 79 | - API 80 | - websocket 81 | - mysql 82 | - pgsql 83 | - SQLServer 84 | - Oracle 85 | - es 86 | - redis 87 | - MongoDB 88 | ## 系统支持 89 | 90 | 稳定支持Linux CentOS系统 91 | 92 | ## 示例 93 | 94 | - ![http://www.kwcnet.com/assets/img/huabei1.png](http://www.kwcnet.com/assets/img/huabei1.png) 95 | - ![http://www.openbi.com.cn/upload/20191118/c36bbd258b7ee694eb987221b2b197b0/d0c06fd3b4b6642248a20814924b9c79.jpg](http://www.openbi.com.cn/upload/20191118/c36bbd258b7ee694eb987221b2b197b0/d0c06fd3b4b6642248a20814924b9c79.jpg) 96 | - ![http://www.openbi.com.cn/upload/20191118/bff139fa05ac583f685a523ab3d110a0/b522c00ca66c5f633770bf2836e8e460.png](http://www.openbi.com.cn/upload/20191118/bff139fa05ac583f685a523ab3d110a0/b522c00ca66c5f633770bf2836e8e460.png) 97 | - ![http://www.kwcnet.com/assets/img/lvyou.png](http://www.kwcnet.com/assets/img/lvyou.png) 98 | - ![http://www.kwcnet.com/Images/e03eed0554c8b59707288bd4983f9518.jpg](http://www.kwcnet.com/Images/e03eed0554c8b59707288bd4983f9518.jpg) 99 | - ![http://www.kwcnet.com/Images/1fb4de3967a2992258e05edd7b5f0127.png](http://www.kwcnet.com/Images/1fb4de3967a2992258e05edd7b5f0127.png) 100 | 101 | ## License 102 | 103 | 遵循nc开源协议发布,并提供个人免费使用。 104 | 105 | ## 官方QQ技术交流群 106 | 107 | 328601229 (QQ群号) 108 | 109 | 110 | ## 商务垂询 111 | 黄成:13370182900(非购买商业授权勿扰) 112 | -------------------------------------------------------------------------------- /Socket_server.php: -------------------------------------------------------------------------------- 1 | on('open' , function ($ws , $request){ 14 | var_dump("客户端-{$request->fd}连接"); 15 | }); 16 | 17 | 18 | $ws->on('message', function( $ws , $request ) { 19 | if($request->data == "ping") { 20 | $ws->push($request->fd, "pong"); 21 | }else { 22 | go(function () use ($ws , $request){ 23 | $GLOBALS[$request->fd] = swoole_timer_tick(1000, function ($timer_id) use ($ws , $request){ 24 | try{ 25 | //var_dump($request->data); 26 | $result = isJson($request->data , true); 27 | //var_dump($result); 28 | $id = $result["sid"]; 29 | $curlData = file_get_contents(WEB_PATH."/index/Websocket/index?id=".$id); 30 | $user_message = $curlData; 31 | if(!empty(json_decode($user_message, 1)["data"])){ 32 | $ws->push($request->fd, $user_message); 33 | } 34 | } catch (\Exception $e) { 35 | 36 | } 37 | //var_dump($user_message); 38 | }); 39 | }); 40 | } 41 | }); 42 | 43 | function isJson($data = '', $assoc = false) { 44 | $data = json_decode($data, $assoc); 45 | if ($data && (is_object($data)) || (is_array($data) && !empty(current($data)))) { 46 | return $data; 47 | } 48 | return false; 49 | } 50 | 51 | 52 | 53 | $ws->on('close',function($ws,$request){ 54 | if(isset($GLOBALS[$request])) { 55 | $result = swoole_timer_clear($GLOBALS[$request]); 56 | var_dump($result); 57 | } 58 | var_dump("客户端-{$request}断开连接"); 59 | }); 60 | 61 | $ws->start(); 62 | 63 | class Env 64 | { 65 | const ENV_PREFIX = 'PHP_'; 66 | 67 | /** 68 | * 加载配置文件 69 | * @access public 70 | * @param string $filePath 配置文件路径 71 | * @return void 72 | */ 73 | public static function loadFile(string $filePath):void 74 | { 75 | if (!file_exists($filePath)) throw new \Exception('配置文件' . $filePath . '不存在'); 76 | //返回二位数组 77 | $env = parse_ini_file($filePath, true); 78 | foreach ($env as $key => $val) { 79 | $prefix = static::ENV_PREFIX . strtoupper($key); 80 | if (is_array($val)) { 81 | foreach ($val as $k => $v) { 82 | $item = $prefix . '_' . strtoupper($k); 83 | putenv("$item=$v"); 84 | } 85 | } else { 86 | putenv("$prefix=$val"); 87 | } 88 | } 89 | } 90 | 91 | /** 92 | * 获取环境变量值 93 | * @access public 94 | * @param string $name 环境变量名(支持二级 . 号分割) 95 | * @param string $default 默认值 96 | * @return mixed 97 | */ 98 | public static function get(string $name, $default = null) 99 | { 100 | $result = getenv(static::ENV_PREFIX . strtoupper(str_replace('.', '_', $name))); 101 | 102 | if (false !== $result) { 103 | if ('false' === $result) { 104 | $result = false; 105 | } elseif ('true' === $result) { 106 | $result = true; 107 | } 108 | return $result; 109 | } 110 | return $default; 111 | } 112 | } -------------------------------------------------------------------------------- /application/.htaccess: -------------------------------------------------------------------------------- 1 | deny from all -------------------------------------------------------------------------------- /application/addons/cache/Common.php: -------------------------------------------------------------------------------- 1 | ['>=', $tid]]; 19 | self::cacheMore($where); 20 | } 21 | 22 | } 23 | 24 | public static function cacheMore($where) 25 | { 26 | $allChart = Screenchart::getChartInfo($where); 27 | foreach ($allChart as $chart) { 28 | self::cacheChart($chart); 29 | } 30 | } 31 | public static function cacheAll() 32 | { 33 | $allChart = Screenchart::getAllChart(); 34 | foreach ($allChart as $chart) { 35 | self::cacheChart($chart); 36 | } 37 | } 38 | // 缓存单图表 39 | public static function cacheSingle($tid) 40 | { 41 | $chart = Screenchart::getSingleChart($tid); 42 | self::cacheChart($chart); 43 | } 44 | // 缓存大屏图表 45 | public static function cacheScreen($screenid) 46 | { 47 | $allChart = Screenchart::getScreenchart($screenid); 48 | foreach ($allChart as $chart) { 49 | self::cacheChart($chart); 50 | } 51 | self::cacheScreen($allChart); 52 | } 53 | // public function getChartCache($tid) 54 | // { 55 | // return \think\Cache::get(Common::getTidDataCacheName($chart['tid'])); 56 | // } 57 | // public function getScreenCache($screenid) 58 | // { 59 | // return \think\Cache::get(Common::getScreenidDataCacheName($chart['screenid'])); 60 | // } 61 | 62 | // 缓存单一图表 63 | protected static function cacheChart($chart) 64 | { 65 | \think\Cache::set(Common::getTidDataCacheName($chart['tid']), $chart->toArray()); 66 | } 67 | // 缓存大屏图表 68 | protected static function cacheScreenchart() 69 | { 70 | \think\Cache::set(Common::getScreenidDataCacheName($chart['screenid']), collection($chart)->toArray()); 71 | } 72 | } -------------------------------------------------------------------------------- /application/addons/cache/hook/ChartProcess.php: -------------------------------------------------------------------------------- 1 | field('tid')->where('screenid', $screenid)->select(); 33 | // 无数据返回 34 | if (!$chartInfos) return []; 35 | $data = []; 36 | foreach ($chartInfos as $chartInfo) { 37 | $data += self::processChart($chartInfo['tid']); 38 | } 39 | return $data; 40 | } 41 | // 单图表处理 42 | public static function processChart($tid) 43 | { 44 | //根据id从缓存里拿到图表数据 45 | $chartCache = Common::getChartCache($tid); 46 | $data[$chartCache['tname']] = self::processSingleChart($chartCache); 47 | return $data; 48 | } 49 | protected static function processSingleChart($chartCache) 50 | { 51 | // 实时数据 52 | $realTimeData = self::getRealTimeData($chartCache); 53 | if (!isset($realTimeData[0]) && $chartCache['chartSourceType']) return $chartCache['name'].'无法获取数据'; 54 | $mapData = self::mapping($realTimeData, $chartCache['maps']); 55 | if (!$mapData) return $chartCache['name'].'数据映射有误!'; 56 | return Chart::index($chartCache['charttype'], $mapData, $chartCache['name']); 57 | } 58 | // 获取实时数据 59 | protected static function getRealTimeData($data) 60 | { 61 | // 图片等类型无数据类型的返回空 62 | if (!method_exists(__CLASS__, $data['chartSourceType'])) return $data['dataInfo']; 63 | // 其他有类型的 64 | return self::{$data['chartSourceType']}($data); 65 | } 66 | // 映射 67 | public static function mapping($realTimeData, $maps) 68 | { 69 | $realTimeData = is_array($realTimeData) ? $realTimeData : json_decode($realTimeData, true); 70 | if (!$maps) return $realTimeData; 71 | foreach ($realTimeData as &$value) { 72 | foreach ($maps as $newKey => $oldKey) { 73 | if (!isset($value[$oldKey])) return false; 74 | if ($oldKey == $newKey) continue; 75 | $value[$newKey] = $value[$oldKey]; 76 | unset($value[$oldKey]); 77 | } 78 | } 79 | return $realTimeData; 80 | } 81 | 82 | protected static function static($data) 83 | { 84 | return $data['tdata']; 85 | } 86 | protected static function api($data) 87 | { 88 | try{ 89 | //直接从API里面取值 90 | $results = file_get_contents($data['filepath'] , false , stream_context_create(array( 91 | "ssl"=>array( 92 | "verify_peer"=>false, 93 | "verify_peer_name"=>false, 94 | ), 95 | ))); 96 | //如果返回值为XML则转成json 97 | if(xml_parser($results)){ 98 | $xml =simplexml_load_string($results); 99 | $xmljson= json_encode($xml); 100 | $result=json_decode($xmljson,true); 101 | }else{ 102 | $result=json_decode($results,true); 103 | } 104 | 105 | return $result; 106 | } catch (\Exception $e) { 107 | return false; 108 | } 109 | } 110 | protected static function sql($data) 111 | { 112 | //通过数据库配置ID拿到数据库配置 113 | $config = Db::name('databasesource')->where('baseid' , $data['sid'])->find(); 114 | //判断是否查询成功 115 | if (!$config) return false; 116 | $config = json_decode($config['baseconfig'],1); 117 | $config['password'] = decrypt($config['password'],$config['len']); 118 | //连接数据库执行sql 119 | return \DataSource::connect($config)->query($data['returnsql']); 120 | } 121 | protected static function webSocket($data) 122 | { 123 | try{ 124 | //直接从API里面取值 125 | $results = file_get_contents($data['filepath'] , false , stream_context_create(array( 126 | "ssl"=>array( 127 | "verify_peer"=>false, 128 | "verify_peer_name"=>false, 129 | ), 130 | ))); 131 | //如果返回值为XML则转成json 132 | if(xml_parser($results)){ 133 | $xml =simplexml_load_string($results); 134 | $xmljson= json_encode($xml); 135 | $result=json_decode($xmljson,true); 136 | }else{ 137 | $result=json_decode($results,true); 138 | } 139 | return $result; 140 | } catch (\Exception $e) { 141 | return false; 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /application/addons/cache/model/Datament.php: -------------------------------------------------------------------------------- 1 | data['data']; 12 | } 13 | } -------------------------------------------------------------------------------- /application/addons/cache/model/Screenchart.php: -------------------------------------------------------------------------------- 1 | hasOne('Screencharttconfig','tid', 'tid')->bind('name,chartSourceType,charttype,dataOpt,maps'); 12 | } 13 | public function datament() 14 | { 15 | return $this->hasOne('Datament','daid', 'daid')->bind('filepath,datatype,returnsql,sid,dataInfo'); 16 | } 17 | 18 | 19 | // 获取所有图表数据 20 | public static function getAllChart() 21 | { 22 | return self::with('charttconfig,datament')->field('daid,screenid,tid,tname,tdata')->select(); 23 | } 24 | // 获取单个图表数据 25 | public static function getSingleChart($tid) 26 | { 27 | return self::with('charttconfig,datament')->field('daid,screenid,tid,tname,tdata')->where('tid', $tid)->find(); 28 | } 29 | // 获取大屏图表数据 30 | public static function getScreenChart($screenid) 31 | { 32 | return self::with('charttconfig,datament')->field('daid,screenid,tid,tname,tdata')->where('screenid', $screenid)->select(); 33 | } 34 | // 由条件获取图表数据 35 | public static function getChartInfo($where = []) 36 | { 37 | return self::with('charttconfig,datament')->field('daid,screenid,tid,tname,tdata')->where($where)->select(); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /application/addons/cache/model/Screencharttconfig.php: -------------------------------------------------------------------------------- 1 | dataOpt['map']) ? array_filter(array_combine(array_column($this->dataOpt['map'], 0), array_column($this->dataOpt['map'], 1))) : []; 16 | } 17 | } -------------------------------------------------------------------------------- /application/base/controller/Addons.php: -------------------------------------------------------------------------------- 1 | module()); 13 | $controller = strtolower(request()->controller()); 14 | $action = strtolower(request()->action()); 15 | $path = $module .'/'. $controller .'/'.$action; 16 | // 插件规则 17 | $addonConfig = config('addons'); 18 | foreach ($addonConfig as $pluginName => $pluginConfig) { 19 | $pluginConfig['enabled'] = $pluginConfig['enabled'] ?? 'true'; 20 | if (isset($pluginConfig['role'][$path]) && $pluginConfig['enabled']) { 21 | \think\Hook::add($pluginConfig['role'][$path][0], $pluginConfig['role'][$path][1]); 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /application/base/controller/Base.php: -------------------------------------------------------------------------------- 1 | request = $request; 44 | 45 | $request = Request::instance(); 46 | //获取当前模块 47 | $module = strtolower($request->module()); 48 | //获取当前控制器 49 | $controller = strtolower($request->controller()); 50 | //获取当前方法 51 | $action = strtolower($request->action()); 52 | 53 | 54 | 55 | //接口为index/index/index 不使用base; 56 | if($module ==='index' && $controller == 'index' && $action == 'index') { 57 | return 1; 58 | } 59 | //给定一个解救标识 60 | $getScreenInfo = 0; 61 | //接口为index/index/singlescreensummary 不使用base; 62 | if($module ==='index' && $controller == 'index' && $action == 'getscreeninfo') { 63 | //将接口标识设置为true 64 | $getScreenInfo = 1; 65 | } 66 | //接口为index/index/singlescreensummary 不使用base; 67 | if($module ==='index' && $controller == 'index' && $action == 'singlescreensummary') { 68 | //将接口标识设置为true 69 | $getScreenInfo = 1; 70 | } 71 | 72 | if(!$getScreenInfo){ 73 | //初始化userModel 74 | $this->userModel = new UserModel(); 75 | //获取uid和token 76 | $arr = get_all_header(); 77 | if(isset($arr['token'])){ 78 | $this->token = $arr['token']; 79 | }else { 80 | $data = get_status(1,'非法用户访问' ,10001 ); 81 | ajaxReturn($data); 82 | } 83 | $input['token'] = $arr['token']; 84 | $getUid = $this->userModel->getMessg('token' ,['token' => $arr['token']]); 85 | if(!$getUid) { 86 | $data = get_status(1,'Token验证失败' , 10002); 87 | ajaxReturn($data); 88 | } 89 | $input['uid'] = $getUid[0]['uid']; 90 | $uid = $input['uid']; 91 | 92 | //将用户信息存入变量 93 | $user = $this->userModel->getUser($uid); 94 | if($user){ 95 | $this->user = $user; 96 | } 97 | // 查询token过期时间 98 | $token = $this->userModel->getMessg('token' , ['token' => $input['token']]); 99 | //判断token是否存在 100 | if($token){ 101 | //判断token是否过期 102 | if(time() > $token[0]['tokentime']){ 103 | //token过期 删除token 同时登录-1 104 | $userTokenDel = $this->userModel->getMessg('user' , ['uid' => $input['uid']]); 105 | $online = $userTokenDel[0]['online'] - 1; 106 | //ajaxReturn($online); 107 | $userTokenDel = $this->userModel->updateMessg('user' , ['uid' => $input['uid']] , ['online' => $online]); 108 | $tokendel = $this->userModel->deleteMessg('token' , ['token' => $input['token']]); 109 | $data = get_status(1,'由于您长时间未操作系统自动退出' , 10003); 110 | ajaxReturn($data); 111 | }else { 112 | //token未过期 ,操作加token过期时间 113 | $data = [ 114 | 'tokentime' => time()+720000 115 | ]; 116 | $tokentime = $this->userModel->updateMessg('token' , ['token' => $input['token']] , $data); 117 | } 118 | }else{ 119 | $data = get_status(1,'请先登录' , 10004); 120 | ajaxReturn($data); 121 | } 122 | 123 | //通过用户id获得角色id 124 | $result = $this->userModel->getRole($this->user['uid']); 125 | if($result) { 126 | $rid = $result['rid']; 127 | }else{ 128 | $data = get_status(1,'该用户没有指定角色',1004 ); 129 | ajaxReturn($data); 130 | } 131 | 132 | //通过角色ID获得角色名称 133 | $result = $this->userModel->getRolename($rid); 134 | 135 | //将角色组存入用户变量 136 | $this->role = $result; 137 | 138 | //通过角色ID获得权限ID 139 | $result = $this->userModel->getPid($rid); 140 | if($result) { 141 | $pid = $result['pid']; 142 | }else{ 143 | $arr = get_status(1,'无权限访问',0005); 144 | ajaxReturn($arr); 145 | } 146 | 147 | //通过权限ID获取权限列表 148 | $result = $this->userModel->getPermission($pid); 149 | if($result) { 150 | //将用户权限存入变量 151 | $this->permission = $result; 152 | }else{ 153 | $arr = get_status(1,'无权限访问',0005); 154 | ajaxReturn($arr); 155 | } 156 | 157 | if(!$this->token){ 158 | $arr = get_status(1,'无权限访问',0005); 159 | ajaxReturn($arr); 160 | } 161 | 162 | 163 | 164 | //定义i判断条件 1为没有权限 0位通过权限验证 165 | $m = $module .'/'. $controller .'/'.$action; 166 | $i = 1; 167 | 168 | foreach ($this->permission as $value) { 169 | //判断用户有没有操作该操作的权利 170 | if(trim(strtolower($value['urlm'])) == strtolower($module) && trim(strtolower($value['urlc'])) == strtolower($controller) && trim(strtolower($value['urla'])) == strtolower($action)) { 171 | $i = 0; 172 | break; 173 | } 174 | } 175 | 176 | //处理lv为2的权限 177 | //查询接口 178 | $urlLv = $this->userModel->getMessg('permission' , ['urlm' =>$module , 'urlc' => $controller , 'urla' => $action]); 179 | 180 | //判断lv是否是2 181 | if($urlLv) { 182 | if($urlLv[0]['lv'] == 2){ 183 | $i = 0; 184 | } 185 | } 186 | 187 | if($i){ 188 | unset($i); 189 | $arr = get_status(1,'没有操作权限',0006); 190 | ajaxReturn($arr); 191 | } 192 | } 193 | } 194 | 195 | 196 | //获取用户权限列表 197 | public function getPermission($uid) 198 | { 199 | //将用户信息存入变量 200 | $user = $this->userModel->getUser($uid); 201 | if($user){ 202 | $this->user = $user; 203 | } 204 | 205 | //通过用户id获得角色id 206 | $result = $this->userModel->getRole($uid); 207 | if($result) { 208 | $rid = $result['rid']; 209 | }else{ 210 | // ajaxReturn_encode(['err' => 1 ,'data' => '该用户没有指定角色']); 211 | $data = get_status(1,'该用户没有指定角色' , 1004 ); 212 | return $data; 213 | } 214 | 215 | //通过角色ID获得角色名称 216 | $result = $this->userModel->getRolename($rid); 217 | 218 | //将角色名称存入用户变量 219 | $this->rolename = $result['rolename']; 220 | 221 | //通过角色ID获得权限ID 222 | $result = $this->userModel->getPid($rid); 223 | if($result) { 224 | $rid = $result['pid']; 225 | }else{ 226 | return false; 227 | } 228 | 229 | //通过权限ID获取权限列表 230 | $result = $this->userModel->getPermission($rid); 231 | if($result) { 232 | //将用户权限存入变量 233 | return $result; 234 | }else{ 235 | return false; 236 | } 237 | } 238 | 239 | } -------------------------------------------------------------------------------- /application/command.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return []; 13 | -------------------------------------------------------------------------------- /application/common.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // 应用公共文件 13 | 14 | 15 | function get_status($err, $da, $status = null) 16 | { 17 | $data['err'] = $err; 18 | $data['data'] = $da; 19 | if ($data['err']) { 20 | $data['status'] = $status; 21 | } 22 | return $data; 23 | } 24 | 25 | 26 | function get_Log($username, $operation, $state) 27 | { 28 | Db::name('log')->insert(['username'=>$username,'operation'=>$operation,'state'=>$state]); 29 | } 30 | 31 | 32 | function get_types($filename) 33 | { 34 | $type = substr($filename, strrpos($filename, ".")+1); 35 | return $type; 36 | } 37 | 38 | function ajaxReturn($data) 39 | { 40 | exit(json_encode($data)) ; 41 | } 42 | 43 | 44 | //获取header头中的值(token) 45 | function get_all_header() 46 | { 47 | // 忽略获取的header数据。这个函数后面会用到。主要是起过滤作用 48 | $ignore = array('host','accept','content-length','content-type'); 49 | 50 | $headers = array(); 51 | //这里大家有兴趣的话,可以打印一下。会出来很多的header头信息。咱们想要的部分,都是‘http_'开头的。所以下面会进行过滤输出。 52 | /* var_dump($_SERVER); 53 | exit;*/ 54 | 55 | foreach ($_SERVER as $key=>$value) { 56 | if (substr($key, 0, 5)==='HTTP_') { 57 | //这里取到的都是'http_'开头的数据。 58 | //前去开头的前5位 59 | $key = substr($key, 5); 60 | //把$key中的'_'下划线都替换为空字符串 61 | $key = str_replace('_', ' ', $key); 62 | //再把$key中的空字符串替换成‘-’ 63 | $key = str_replace(' ', '-', $key); 64 | //把$key中的所有字符转换为小写 65 | $key = strtolower($key); 66 | 67 | //这里主要是过滤上面写的$ignore数组中的数据 68 | if (!in_array($key, $ignore)) { 69 | if ($key == "access-token") { 70 | $headers['token'] = $value; 71 | } else { 72 | $headers[$key] = $value; 73 | } 74 | } 75 | } 76 | } 77 | //输出获取到的header 78 | return $headers; 79 | } 80 | 81 | 82 | /** 83 | * 判断传过来的键是否存在 84 | * 85 | * */ 86 | function valiKeys($keys, $input) 87 | { 88 | //遍历键 89 | foreach ($keys as $k => $v) { 90 | if (!isset($input[$v])) { 91 | return get_status(1, $v.'未设置'); 92 | } 93 | } 94 | return get_status(0, []); 95 | } 96 | 97 | 98 | /** 99 | * 默认返回为html是返回json格式 100 | */ 101 | function jsonRetuen($err, $data, $status = null) 102 | { 103 | if ($status) { 104 | return json(['err' => $err , 'data' => $data,'status'=>$status]); 105 | } else { 106 | return json(['err' => $err , 'data' => $data]); 107 | } 108 | } 109 | 110 | 111 | /** 112 | * @Notes : 解密 113 | * @access : $password : 解密内容 114 | * @author : wwk 115 | * @Time: 2018/08/13 11:23 116 | */ 117 | function decrypt($password, $len) 118 | { 119 | $key = 'kwc.net'; 120 | $str = openssl_decrypt($password, 'aes-128-cbc', $key, 2); 121 | $pwd = substr($str, 0, $len); 122 | return $pwd; 123 | } 124 | 125 | //获取配置文件信息 126 | function configJson() 127 | { 128 | //获取配置文件信息 129 | $file = file_get_contents(config('static_config_path')); 130 | //将配置文件转换数组 131 | $arr = json_decode($file, 1); 132 | if (!$arr) { 133 | $arr = json_decode(trim($file,chr(239).chr(187).chr(191)),true); 134 | } 135 | //返回配置文件信息及路径 136 | return ['config' => $arr , 'path' => config('static_config_path')]; 137 | } 138 | 139 | 140 | //处理base64图片 141 | function base64Image($data) 142 | { 143 | if (!is_string($data) || $data == '') { 144 | return false; 145 | } 146 | $base64 = $data; 147 | $arr = explode(',', $base64); 148 | //取出后缀 149 | $ext = base64Ext($arr[0]); 150 | //取出base64图片字符串 151 | $base64Str = $arr[1]; 152 | $file = base64_decode($base64Str); 153 | //定义图片名称 154 | $fileName = md5(mt_rand(100, 999).time()).'.'.$ext; 155 | //定义图片路径 156 | $filePath = ROOT_PATH . 'public' . DS . 'uploads' . DS . date('Ymd', time()); 157 | if (!file_exists($filePath)) { 158 | mkdir($filePath, 0755); 159 | } 160 | //保存图片 161 | $r = file_put_contents($filePath.DS.$fileName, $file); 162 | 163 | if ($r) { 164 | //获取图片相对路径 165 | $imgPath = str_replace(ROOT_PATH, '', $filePath.DS.$fileName); 166 | return $imgPath; 167 | } else { 168 | return false; 169 | } 170 | } 171 | 172 | 173 | // 传入base64前部分带有照片后缀的字符串 174 | function base64Ext($str) 175 | { 176 | $step1 = explode('/', $str); 177 | $step2 = explode(';', $step1[1]); 178 | return $step2[0]; 179 | } 180 | 181 | 182 | //模型统一判断返回格式 183 | function agreeReturn($result) 184 | { 185 | if ($result) { 186 | return $result; 187 | } 188 | return false; 189 | } 190 | 191 | //判断键是否存在,不存在给默认值 192 | function issetKey($input, $key, $value) 193 | { 194 | if (!isset($input[$key])) { 195 | $input[$key] = $value; 196 | } else { 197 | $input[$key] = rtrim(strtolower($input[$key])); 198 | } 199 | return $input[$key]; 200 | } 201 | 202 | //判断xml格式 203 | //自定义xml验证函数xml_parser() 204 | function xml_parser($str) 205 | { 206 | $xml_parser = xml_parser_create(); 207 | if (!xml_parse($xml_parser, $str, true)) { 208 | xml_parser_free($xml_parser); 209 | return false; 210 | } else { 211 | return (json_decode(json_encode(simplexml_load_string($str)), true)); 212 | } 213 | } 214 | 215 | 216 | function curl_request($url, $opt = []) 217 | { 218 | $sec = $opt['sec'] ?? 3; 219 | $method = $opt['method'] ?? 'GET'; 220 | $headers = $opt['headers'] ?? []; 221 | $params = $opt['params'] ?? []; 222 | if (is_array($params)) { 223 | $requestString = http_build_query($params); 224 | } else { 225 | $requestString = $params ? : ''; 226 | } 227 | if (empty($headers)) { 228 | $headers = array('Content-type: text/json'); 229 | } elseif (!is_array($headers)) { 230 | parse_str($headers, $headers); 231 | } 232 | $ch = curl_init(); 233 | curl_setopt($ch, CURLOPT_URL, $url); 234 | curl_setopt($ch, CURLOPT_VERBOSE, 1); 235 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 236 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 237 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 238 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 239 | curl_setopt($ch, CURLOPT_TIMEOUT, $sec); 240 | curl_setopt($ch, CURLOPT_POST, 1); 241 | switch (strtoupper($method)) { 242 | case "GET": curl_setopt($ch, CURLOPT_HTTPGET, 1);break; 243 | case "POST": curl_setopt($ch, CURLOPT_POST, 1); 244 | curl_setopt($ch, CURLOPT_POSTFIELDS, $requestString);break; 245 | case "PUT": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); 246 | curl_setopt($ch, CURLOPT_POSTFIELDS, $requestString);break; 247 | case "DELETE": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 248 | curl_setopt($ch, CURLOPT_POSTFIELDS, $requestString);break; 249 | } 250 | $response = curl_exec($ch); 251 | curl_close($ch); 252 | if (stristr($response, 'HTTP 404') || $response == '') { 253 | return array('Error' => '请求错误'); 254 | } 255 | return $response; 256 | } 257 | -------------------------------------------------------------------------------- /application/database.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | use think\Env; 13 | 14 | return [ 15 | // 数据库类型 16 | 'type' => 'mysql', 17 | // 服务器地址 18 | 'hostname' => Env::get('database.hostname'), 19 | // 数据库名 20 | 'database' => Env::get('database.database'), 21 | //用户名 22 | 'username' => Env::get('database.username'), 23 | // 密码 24 | 'password' => Env::get('database.password'), 25 | // 端口 26 | 'hostport' => Env::get('database.hostport'), 27 | // 连接dsn 28 | 'dsn' => '', 29 | // 数据库连接参数 30 | 'params' => [], 31 | // 数据库编码默认采用utf8 32 | 'charset' => Env::get('database.charset'), 33 | // 数据库表前缀 34 | 'prefix' => Env::get('database.prefix'), 35 | // 数据库调试模式 36 | 'debug' => Env::get('database.debug'), 37 | // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 38 | 'deploy' => 0, 39 | // 数据库读写是否分离 主从式有效 40 | 'rw_separate' => false, 41 | // 读写分离后 主服务器数量 42 | 'master_num' => 1, 43 | // 指定从服务器序号 44 | 'slave_no' => '', 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 | ]; -------------------------------------------------------------------------------- /application/extra/addons.php: -------------------------------------------------------------------------------- 1 | [ 5 | // 是否开启缓存 6 | 'enabled' => true, 7 | // 图表数据(api,静态,sql等) 8 | 'config' => [ 9 | 'tidChartData' => 'tiddata', 10 | 'screenidChartData' => 'screeniddata', 11 | ], 12 | // 增加监听 13 | 'role'=>[ 14 | 'index/screen/updatechart' => ['app_end', 'app\\addons\\cache\\hook\\CacheChartInfo'], 15 | 'index/screen/addchart' => ['app_end', 'app\\addons\\cache\\hook\\CacheChartInfo'], 16 | 'index/screen/chartcopy' => ['app_end', 'app\\addons\\cache\\hook\\CacheChartInfo'], 17 | ], 18 | ], 19 | ]; -------------------------------------------------------------------------------- /application/extra/chartType.php: -------------------------------------------------------------------------------- 1 | 9 | //折线图,散点图,柱状图 10 | "line", 11 | 12 | "line"=> 13 | //折线图,散点图,柱状图 14 | "line", 15 | 16 | "pie" => 17 | //饼图 18 | "pie", 19 | 20 | "wangye" => 21 | //web 22 | "web", 23 | 24 | "lunbotu" => 25 | //轮播图 26 | "carousel", 27 | 28 | "fuwenben"=> 29 | //richtxt 30 | "web", 31 | 32 | "jishuban"=> 33 | //计数板 34 | "web", 35 | 36 | "duoxingwenben"=> 37 | //richtxt 38 | "web", 39 | 40 | "paomadeng"=> 41 | //richtxt 42 | "web", 43 | 44 | "jindutiao"=> 45 | //richtxt 46 | "web", 47 | 48 | "huanxingjindutiao"=> 49 | //richtxt 50 | "web", 51 | 52 | "biaoge" => 53 | //表格 54 | "lunbotable", 55 | 56 | "lunbobiaoge" => 57 | //表格 58 | "lunbotable", 59 | 60 | "scatter" => 61 | //散点图 62 | "scatter", 63 | 64 | //下面为大改之后 65 | "biaozhuduibibingtu" => 66 | "pie1", 67 | 68 | "daitubingtu" => 69 | //饼图 70 | "pie1", 71 | 72 | "jibenbingtu" => 73 | //饼图 74 | "pie1", 75 | 76 | "huanshanbingtu" => 77 | //饼图 78 | "pie1", 79 | 80 | "lunbobingtu" => 81 | //饼图 82 | "pie1", 83 | 84 | "zhibiaoduibibingtu" => 85 | //饼图 86 | "pie1", 87 | 88 | "zhibiaozhanbibingtu" => 89 | //饼图 90 | "pie3", 91 | 92 | "duoweidubingtu" => 93 | //饼图 94 | "pie", 95 | 96 | "banmazhutu" => 97 | //柱状图 98 | "bar1", 99 | 100 | "chuizhijibenzhutu" => 101 | //柱状图 102 | "bar1", 103 | 104 | "chuizhijiaonanzhutu" => 105 | //柱状图 106 | "bar1", 107 | 108 | "fenzuzhutu" => 109 | //柱状图 110 | "bar1", 111 | 112 | "huxingzhutu" => 113 | //柱状图 114 | "huxingzhutu", 115 | 116 | "jibenzhutu" => 117 | //柱状图 118 | "bar1", 119 | 120 | "shuipingjibenzhutu" => 121 | //柱状图 122 | "bar1", 123 | 124 | "shuipingjiaonanzhutu" => 125 | //柱状图 126 | "bar1", 127 | 128 | "tixingzhutu" => 129 | //柱状图 130 | "bar1", 131 | 132 | "zhexianzhutu" => 133 | //柱状图 134 | "bar2", 135 | 136 | "jibenzhexiantu" => 137 | //柱状图 138 | "bar1", 139 | 140 | "quyutu" => 141 | //柱状图 142 | "bar1", 143 | 144 | "quyufanpaiqi" => 145 | //柱状图 146 | "bar1", 147 | 148 | "shuangzhouzhexiantu" => 149 | //柱状图 150 | "line4", 151 | 152 | "qipaotu" => 153 | //散点图 154 | "scatter2", 155 | 156 | "sandiantu" => 157 | //散点图 158 | "scatter2", 159 | 160 | "ciyun" => 161 | //词云 162 | "wordCloud", 163 | 164 | "loudoutu" => 165 | //词云 166 | "funnel", 167 | 168 | "shuiqiutu" => 169 | //liquidFill 170 | "liquidFill", 171 | 172 | "yibiaopan" => 173 | //gauge 174 | "gauge", 175 | 176 | "leidatu" => 177 | //gauge 178 | "radar", 179 | 180 | "xiangxingtu" => 181 | //boxplot 182 | "boxplot", 183 | 184 | "relitu" => 185 | //gridheatmap 186 | "gridheatmap", 187 | 188 | "guanxiwangluo" => 189 | //graph 190 | "graph", 191 | 192 | "zhongguoditu" => 193 | //chinamap 194 | "chinamap", 195 | 196 | "3dzhongguoditu" => 197 | //chinamap 198 | "chinamap3d", 199 | 200 | "sandianzhexiantu" => 201 | //chinamap 202 | "scatter3", 203 | 204 | "qipaozhexiantu" => 205 | //chinamap 206 | "scatter3", 207 | 208 | "danzhouzhexianzhutu" => 209 | //chinamap 210 | "bar11", 211 | 212 | "3dzhuzhuangtu" => 213 | //chinamap 214 | "bar12", 215 | 216 | "juxingshutu" => 217 | //chinamap 218 | "rectangletree", 219 | 220 | "shijieditu" => 221 | //chinamap 222 | "worldMap", 223 | 224 | "diqiuyi" => 225 | //chinamap 226 | "globechart", 227 | 228 | "3dshijieditu" => 229 | //chinamap 230 | "worldMap3d", 231 | 232 | "gismap" => 233 | //chinamap 234 | "chinamap", 235 | 236 | "sangjitu" => 237 | //chinamap 238 | "sankey", 239 | 240 | "hexiantu" => 241 | //chinamap 242 | "graph", 243 | 244 | "shuangxianghengxiangzhuzhuangtu" => 245 | //chinamap 246 | "bar1", 247 | 248 | "jishubanpro" => 249 | //chinamap 250 | "web", 251 | 252 | "xuritu" => 253 | //chinamap 254 | "sunburst", 255 | 256 | "3dzhexiantu" => 257 | //chinamap 258 | "line5", 259 | 260 | "xuxianzhexiantu" => 261 | //chinamap 262 | "bar1", 263 | 264 | "huanzhuangfaguangzhanbitu" => 265 | //chinamap 266 | "pie11", 267 | 268 | "danzhibaifenbibingtu" => 269 | //chinamap 270 | "pie3", 271 | 272 | "mubiaozhanbibingtu" => 273 | //chinamap 274 | "pie3", 275 | "nengyuanbiaoge" => 276 | //chinamap 277 | "lunbotable", 278 | 279 | "paimingbiaoge" => 280 | //chinamap 281 | "lunbotable", 282 | 283 | "zhuixingzhutu" => 284 | //chinamap 285 | "bar1", 286 | 287 | "2.5dduidietu" => 288 | //chinamap 289 | "bar1", 290 | 291 | "baifenbiduibibintu" => 292 | //chinamap 293 | "baifenbiduibibintu", 294 | 295 | "jindutiaoxingma" => 296 | //chinamap 297 | "jindutiaoxingma", 298 | 299 | "jianbianzhuzhuangtu" => 300 | //chinamap 301 | "jianbianzhuzhuangtu", 302 | //chinamap 303 | "3dzhuzhuangqushibianhuatu" => 304 | "zhuzhuangqushibianhuatu3d", 305 | //chinamap 306 | "shuipingfaguangzhuzhuangtu" => 307 | "shuipingfaguangzhuzhuangtu", 308 | //chinamap 309 | "fenzujianbianzhuzhuangtu" => 310 | "bar1", 311 | //chinamap 312 | "timelinebar" => 313 | "timelinebar", 314 | //chinamap 315 | "zhexianzhuzhuangtu" => 316 | "zhexianzhuzhuangtu", 317 | //chinamap 318 | "leidabianxingtu" => 319 | "leidabianxingtu", 320 | //chinamap 321 | "shujubingtu" => 322 | "shujubingtu", 323 | 324 | "huanxingshujutu" => 325 | "huanxingshujutu", 326 | 327 | "huanxingbilitu" => 328 | "huanxingbilitu", 329 | 330 | "babianxingtutwo" => 331 | "babianxingtutwo", 332 | "siyecaotu" => 333 | "siyecaotu", 334 | "babianxingtu"=> 335 | "babianxingtu", 336 | //wwk新增 337 | "shebeizhuangtaijiankong" => 338 | "asItIs", //返回原数据 339 | "zhuangtaideng" => 340 | "asItIs",//返回原数据 341 | "shijianzhou" => 342 | "asItIs",//返回原数据 343 | "tixingtu" => 344 | "asItIs",//返回原数据 345 | "shuangyuanhudutu" => 346 | "asItIs",//返回原数据 347 | "banhuanbaifenbitu" => 348 | "asItIs",//返回原数据 349 | "polygongis" => 350 | "polygongis",//gis地图第一版 351 | "xingbienianlingtu" => 352 | "asItIs",//返回原数据 353 | "kxiantu2" => 354 | "kxiantu2",//返回原数据 355 | "amapgis" => 356 | "asItIs",//返回原数据 357 | "cloudComponent" => 358 | "cloudComponent",//需要处理 359 | ]; -------------------------------------------------------------------------------- /application/extra/queue.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | 'connector' => 'Sync' 14 | ]; -------------------------------------------------------------------------------- /application/index/common.php: -------------------------------------------------------------------------------- 1 | ROOT_PATH.'data/',//数据库备份路径 23 | ); 24 | $db= new Backup($config);//实例化数据库备份类进行条用里面的方法。 25 | 26 | $str = trim($post['dataname'],'-1.sql'); 27 | $str = explode('-',$str); 28 | $str = join($str,''); 29 | //dump($str); 30 | $result = $db->downloadFile(strtotime($str)); 31 | if (!empty($result)) { 32 | return get_status(1,$result); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /application/index/controller/Carousel.php: -------------------------------------------------------------------------------- 1 | carousel = Loader::model("Carousel"); 35 | //初始化发布列表model 36 | $this->publish = Loader::model("Publish"); 37 | 38 | } 39 | 40 | public function index() 41 | { 42 | return 1; 43 | } 44 | 45 | /** 46 | * 获取一个ID 47 | * @return mixed 48 | */ 49 | public function getCarouselId() 50 | { 51 | //将创建时间加入data 52 | $data = [ 53 | 'createtime' => time() 54 | ]; 55 | //增加一条记录获取ID 56 | $id = $this->carousel->getInsertID($data); 57 | if($id) { 58 | return get_status(0,intval($id)); 59 | }else { 60 | return get_status(1, "网络繁忙" , 9001); 61 | } 62 | } 63 | 64 | /** 65 | * 添加轮播列表 66 | * @return mixed 67 | */ 68 | public function addCarouselScreen() 69 | { 70 | //获取input数据 71 | $input = input('post.'); 72 | 73 | //判断shareIds是否是数组 74 | if(is_array($input['screens'])) { 75 | $input['screens'] = implode(',' , $input['screens']); 76 | } 77 | $cname = Db::name('carouselrelease')->where('cname',$input['cname'])->find(); 78 | if($cname){ 79 | return get_status(1,'文件名重复',4006); 80 | } 81 | //组合data 82 | $data = [ 83 | 'animation' =>$input['animation'], 84 | 'remarks' =>$input['remarks'], 85 | 'controlPos' => $input['controlPos'], 86 | 'cname' => $input['cname'], 87 | 'screens' => $input['screens'], 88 | 'crIdent' => $input['crIdent'], 89 | 'crLink' => $input['crLink'], 90 | 'time' => intval($input['time']), 91 | 'createtime' =>time(), 92 | 'updatetime' =>time() 93 | ]; 94 | $insert = $this->carousel->getInsertID($data); 95 | 96 | if($insert) { 97 | return get_status(0,"添加成功"); 98 | }else { 99 | return get_status(1, "网络繁忙" , 9001); 100 | } 101 | 102 | } 103 | 104 | //获取轮播图表 105 | public function getCarousel() 106 | { 107 | //获取input数据 108 | $input = input('get.'); 109 | //搜索条件 110 | $where = isset($input['searchword']) ? $input['searchword'] : ''; 111 | //当前页 112 | $currentPage = isset($input['currentPage']) ? $input['currentPage'] : '1'; 113 | //每页显示数 114 | $pageSize = isset($input['pageSize']) ? $input['pageSize'] : '10'; 115 | //排序条件 116 | $order = isset($input['order']) ? $input['order'] : 'cname'; 117 | //查询列表 118 | $result['list'] = $this->carousel->getCarouselListAll($where,$currentPage,$pageSize,$order); 119 | //数据总数 120 | $result['total'] = count(Db::name('carouselrelease')->where('cname','like','%'.$where.'%')->select()); 121 | //将图表地址改为数组 122 | foreach($result['list'] as $k=>&$v){ 123 | $v['screens'] = explode(',',$v['screens']); 124 | } 125 | //直接返回数组 126 | return get_status(0,$result); 127 | } 128 | 129 | /** 130 | * 由ID装换成发布链接 131 | * @param $data 132 | */ 133 | protected function CarouselListURL($data) 134 | { 135 | //设置发布列表查询ID集合 136 | $publishIDs = []; 137 | //将查询出来的轮播列表中的发布ID提取出来 138 | foreach ($data as $key => $value) { 139 | //判断cpid是否有值 140 | if(!empty($value['cpid'])) { 141 | //将cpid切割为数组 142 | $tmpArr= explode(',' , $value['cpid']); 143 | foreach ($tmpArr as $v) { 144 | //提取cpid 145 | $publishIDs[] = $v; 146 | } 147 | //初始化$tmpArr 148 | $tmpArr = []; 149 | } 150 | } 151 | //定义where条件 152 | $where['scid'] =['in' , array_unique($publishIDs)]; 153 | //查询发布列表 154 | $selectList = $this->publish->getWhereList($where,"scid,link"); 155 | $publishList = []; 156 | //将查询结果以pid为键保存 157 | foreach ($selectList as $value) { 158 | $publishList[$value['scid']] = $value['link']; 159 | } 160 | //将$data中的cpid换成具体的link 161 | foreach ($data as $key => $value) { 162 | //判断cpid是否有值 163 | if(!empty($value['cpid'])) { 164 | //将cpid切割为数组 165 | $tmpArr= explode(',' , $value['cpid']); 166 | //将源cpid初始化 167 | $data[$key]['cpid'] = []; 168 | foreach ($tmpArr as $v) { 169 | if(isset($publishList[$v]) ){ 170 | //给cpid重新赋值 171 | $data[$key]['cpid'][] = $publishList[$v]; 172 | } 173 | } 174 | //初始化$tmpArr 175 | $tmpArr = []; 176 | } 177 | } 178 | //返回数组 179 | return $data; 180 | } 181 | 182 | //删除轮播列表 183 | public function delCarousel() 184 | { 185 | //获取input数据 186 | $input = input('get.'); 187 | //验证参数是否正确 188 | //判断shareIds是否是数组 189 | if(is_array($input['crid'])) { 190 | $input['crid'] = implode(',' , $input['crid']); 191 | } 192 | //设置where条件 193 | $where['crid'] = ["in" , $input['crid']]; 194 | //执行删除 195 | $delete = $this->carousel->deleteCarousel($where); 196 | //判断是否删除成功 197 | if($delete) { 198 | return get_status(0 , "删除成功"); 199 | }else { 200 | return get_status(1 , "网路繁忙" , 9001); 201 | } 202 | } 203 | //修改轮播图信息 204 | public function updateCarouselScreen() 205 | { 206 | $put = input('put.'); 207 | $cname = Db::name('carouselrelease')->where('crid','<>',$put['crid'])->where('cname',$put['cname'])->find(); 208 | if($cname){ 209 | return get_status(1,'文件名重复',4006); 210 | } 211 | $put['screens'] = implode(',',$put['screens']); 212 | $put['updatetime'] = time(); 213 | $crid = ['crid'=>$put['crid']]; 214 | //删除无用字段 215 | unset($put['crid']); 216 | unset($put['checked']); 217 | $update = $this->carousel->updateCarousel($put,$crid); 218 | if($update){ 219 | return get_status(0,'修改成功'); 220 | }else{ 221 | return get_status(1,'修改失败',6004); 222 | } 223 | } 224 | //展示一个轮播详情 225 | public function getCarouselDetail() 226 | { 227 | $input = input('get.'); 228 | // dump($input);die; 229 | $get = ['crIdent'=>$input['crIdent']]; 230 | $data = $this->carousel->getCarouselList($get); 231 | 232 | $data['screens'] = explode(',',$data['screens']); 233 | return get_status(0,$data); 234 | } 235 | 236 | } -------------------------------------------------------------------------------- /application/index/controller/Datamap.php: -------------------------------------------------------------------------------- 1 | select(); 19 | if(empty($result)){ 20 | return get_status(1,'没有相应数据类型'); 21 | }else{ 22 | return get_status(0,$result); 23 | } 24 | 25 | } 26 | //根据数据类型查出来的已有数据 27 | public function mapdata() 28 | { 29 | $put = file_get_contents('php://input'); 30 | //$put = '{"dtid":1}'; 31 | $post = json_decode($put,1); 32 | $result = Db::name('datasource')->where('dtid',$post['dtid'])->field('daid,dataname')->select(); 33 | if(empty($result)){ 34 | return get_status(1,'没有相应数据'); 35 | }else{ 36 | return get_status(0,$result); 37 | } 38 | 39 | } 40 | //返回的数据 41 | public function returndata() 42 | { 43 | $put = file_get_contents('php://input'); 44 | //$put = '{"daid":85,"dtid":4}'; 45 | if(empty($put)){ 46 | return get_status(1,NULL); 47 | } 48 | $post = json_decode($put,1); 49 | 50 | if($post['dtid'] == 2){ 51 | $select = Db::name('datasource')->where('daid',$post['daid'])->field('uploadpath')->select(); 52 | $fileSrc = ROOT_PATH . 'public'.$select[0]['uploadpath']; 53 | //$fileSrc = ROOT_PATH . 'public/updirs/国电泰州#3至#4机组对比报表(1月).xlsx'; 54 | //使用phpexcel 55 | Vendor('Classes.PHPExcel'); 56 | $objPHPExcel = IOFactory::load($fileSrc); 57 | //生成返回数据 58 | $result = $objPHPExcel->getSheet(0)->toArray(); 59 | //dump($result); 60 | }elseif($post['dtid'] == 3){ 61 | $result = Db::name('datasource')->where('daid',$post['daid'])->field('uploadpath,autoupdate,request,cookie')->select(); 62 | }else{ 63 | $find = Db::name('datasource')->where('daid',$post['daid'])->field('source,returnsql')->find(); 64 | $select = Db::name('datasource')->where('daid',$find['source'])->field('daid,dataname,host,username,password,port,dbname,len')->select(); 65 | $this->host = $select[0]['host']; 66 | $this->name = $select[0]['username']; 67 | //$this->pwd = $select[0]['password']; 68 | $this->dbname = $select[0]['dbname']; 69 | $port = $select[0]['port']; 70 | $key = 'kwc.net'; 71 | $str = openssl_decrypt($select[0]['password'], 'aes-128-cbc',$key,2); 72 | $pwd = substr($str, 0,$select[0]['len']); 73 | $link = @mysqli_connect($this->host,$this->name,$pwd,$this->dbname,$port); 74 | if(!$link){ 75 | //不成功,返回报错信息 76 | return mysqli_connect_error(); 77 | }else{ 78 | $sqls = mysqli_query($link,$find['returnsql']); 79 | //dump($sqls); 80 | while($row = mysqli_fetch_array($sqls,MYSQLI_ASSOC)){ 81 | $data[] = $row; 82 | } 83 | 84 | 85 | } 86 | foreach ($data as $k => $v) { 87 | $keys = array_keys($v); 88 | $result[] = array_values($v); 89 | 90 | } 91 | array_unshift($result, $keys); 92 | //dump($result); 93 | // $data = json_decode($select[0]['returnjson'],1); 94 | // if (empty($data)) { 95 | // return get_status(1,'没有相应的数据'); 96 | // } 97 | // foreach ($data as $k => $v) { 98 | // $keys = array_keys($v); 99 | // $result[] = array_values($v); 100 | 101 | // } 102 | 103 | // array_unshift($result, $keys); 104 | //dump($result); 105 | 106 | 107 | } 108 | if(empty($result)){ 109 | return get_status(1,'没有相应的数据'); 110 | }else{ 111 | return get_status(0,$result); 112 | } 113 | 114 | } 115 | //存入发布数据 116 | public function publish() 117 | { 118 | $put = file_get_contents('php://input'); 119 | 120 | if(empty($put)){ 121 | return get_status(1,NULL); 122 | } 123 | $post = json_decode($put,1); 124 | $result = Db::name('publish')->insertGetId($post); 125 | 126 | if(empty($result)){ 127 | return get_status(1,NULL); 128 | }else{ 129 | return get_status(0,$result); 130 | } 131 | } 132 | 133 | //发布内容修改 134 | public function pupdate() 135 | { 136 | $put = file_get_contents('php://input'); 137 | if(empty($put)){ 138 | return get_status(1,NULL); 139 | } 140 | $post = json_decode($put,1); 141 | 142 | $result = Db::name('publish')->where('pid',$post['pid'])->update($post); 143 | //dump($result); 144 | if(empty($result)){ 145 | return get_status(1,NULL); 146 | }else{ 147 | return get_status(0,$result); 148 | } 149 | 150 | } 151 | //发布 152 | public function release() 153 | { 154 | $put = file_get_contents('php://input'); 155 | //$put = '{"is_pwd":0,"scid":12,"password":12345}'; 156 | if(empty($put)){ 157 | return get_status(1,NULL); 158 | } 159 | $post = json_decode($put,1); 160 | //$insert = Db::name('publish')->insert($post); 161 | $select = Db::name('publish')->where('pid',$post['pid'])->select(); 162 | //dump($select); 163 | if($select[0]['is_pwd'] == 1){ 164 | // if ($select[0]['password'] == $post['password']) { 165 | // $data = Db::name('screen')->where('id',$post['scid'])->field('data')->select(); 166 | // }else{ 167 | // return get_status(1,'数据库密码错误'); 168 | // } 169 | return get_status(2,NULL); 170 | }else{ 171 | $data = Db::name('screen')->where('id',$select[0]['scid'])->field('data')->find(); 172 | } 173 | if(empty($data)){ 174 | return get_status(1,NULL); 175 | }else{ 176 | return get_status(0,$data['data']); 177 | } 178 | 179 | } 180 | //发布密码 181 | public function pwd() 182 | { 183 | $put = file_get_contents('php://input'); 184 | //$put = '{"is_pwd":0,"scid":12,"password":12345}'; 185 | if(empty($put)){ 186 | return get_status(1,NULL); 187 | } 188 | $post = json_decode($put,1); 189 | $select = Db::name('publish')->where('pid',$post['pid'])->find(); 190 | if($select['password'] == $post['password']){ 191 | $data = Db::name('screen')->where('id',$select['scid'])->field('data')->find(); 192 | }else{ 193 | return get_status(2,'数据库密码错误'); 194 | } 195 | if(empty($data)){ 196 | return get_status(1,NULL); 197 | }else{ 198 | return get_status(0,$data['data']); 199 | } 200 | 201 | } 202 | 203 | } -------------------------------------------------------------------------------- /application/index/controller/Deviceinfo.php: -------------------------------------------------------------------------------- 1 | deviceInfoModel = Loader::model('Deviceinfo'); 19 | } 20 | 21 | /** 22 | * 产线和设备的信息 23 | */ 24 | public function deviceAll() 25 | { 26 | //所有场景 27 | $Scenes = [ 28 | [ 29 | "value" => 1, 30 | "name" => "场景1", 31 | ], 32 | [ 33 | "value" => 2, 34 | "name" => "场景2", 35 | ], 36 | ]; 37 | //设备 38 | $device = [ 39 | [ 40 | "value" => 1, 41 | "name" => "吹风机1", 42 | ], 43 | [ 44 | "value" => 2, 45 | "name" => "吹风机3", 46 | ], 47 | [ 48 | "value" => 3, 49 | "name" => "吹风机2", 50 | ],[ 51 | "value" => 4, 52 | "name" => "打包机器1", 53 | ], 54 | [ 55 | "value" => 5, 56 | "name" => "打包机器2", 57 | ], 58 | [ 59 | "value" => 5, 60 | "name" => "打包机器3", 61 | ]]; 62 | 63 | //生产线 64 | $ProductionLine = [ 65 | [ 66 | "value" => 1, 67 | "name" => "产线1", 68 | ], 69 | [ 70 | "value" => 2, 71 | "name" => "产线2", 72 | ], 73 | [ 74 | "value" => 3, 75 | "name" => "产线3", 76 | ], 77 | ]; 78 | 79 | return ['err' => 0 ,'data' =>['device' => $device , 'ProductionLine' => $ProductionLine , 'scenes'=> $Scenes]]; 80 | } 81 | 82 | /** 83 | * 场景与设备的绑定 84 | * scenes chainId modelID guid = 3DModelID 对应 场景ID 生产线ID , 设备ID , 模型GUID 85 | */ 86 | public function bindDevice() 87 | { 88 | //获取前端传参 89 | $input = input('post.'); 90 | //验证数据是否是需要的键 91 | $vail = valiKeys(["scenesId","chainId" ,"modelID" ,"guid" ] , $input); 92 | if($vail['err']) { 93 | return get_status(1,$vail['data'].'不能为空',333); 94 | } 95 | //场景的配置 96 | $config = [ 97 | 'guid' => $input['guid'], //模型GUID 3DModelID 98 | 'scenes' => $input['scenesId'], //场景ID 99 | 'modelid' => $input['modelID'], //设备ID 100 | 'chainid' => $input['chainId'], //生产线ID 101 | 102 | ]; 103 | //数据库参数 104 | $data = [ 105 | "scenes" => $input['scenesId'], 106 | 'scenes_config' => json_encode($config), 107 | ]; 108 | //查询数据库是否存在一样的数据 109 | $result = $this->deviceInfoModel->vailBindDevice($data); 110 | if($result) { 111 | return get_status(0,'模型已绑定'); 112 | } 113 | //将创建时间加入到data中 114 | $data['scenes_createtime'] = time(); 115 | //存入数据库 116 | $res = $this->deviceInfoModel->bindDevice($data); 117 | if($res) { 118 | return get_status(0,'模型绑定成功'); 119 | }else { 120 | return get_status(1,'模型绑定失败',1111); 121 | } 122 | } 123 | 124 | } -------------------------------------------------------------------------------- /application/index/controller/Drilldown.php: -------------------------------------------------------------------------------- 1 | where('charttype',$post['drillconfig']['comkey'])->value('data'); 24 | //更新时间 25 | Db::name('screen')->where('id',$post['screenid'])->update(['updatetime' => time()]); 26 | //将默认数据存入数据库中 27 | $input['tid'] = Db::name('screenchart')->insertGetId($data); 28 | //判断是否插入成功 29 | if(!$input['tid']) { 30 | return get_status(1,'添加图表失败',2004); 31 | } 32 | $input['screenid'] = $post['screenid']; 33 | //将图表类型取出 34 | $input['chartSourceType'] = $post['drillconfig']['dataOpt']['source']['type']; 35 | //序列化 36 | $input['dataOpt'] = json_encode($post['drillconfig']['dataOpt']); 37 | 38 | //序列化 39 | $input['chartData'] = json_encode($post['drillconfig']['chartData']); 40 | 41 | $id = [ 42 | //当前下钻图表id 43 | 'drillid' =>$input['tid'], 44 | //下钻图表父级id 45 | 'drillpid'=>$post['tid'], 46 | //下钻图表大屏id 47 | 'drillsid'=>$post['screenid'] 48 | ]; 49 | $post['drillconfig']['drilling'] = Array_merge($id,$post['drillconfig']['drilling']); 50 | 51 | //序列化 52 | if(isset($post['drillconfig']['drilling'])){ 53 | $input['drilling'] = json_encode($post['drillconfig']['drilling']); 54 | } 55 | $input['charttype'] = $post['drillconfig']['charttype']; 56 | $input['name'] = $post['drillconfig']['name']; 57 | $input['comtype'] = $post['drillconfig']['comtype']; 58 | $input['comkey'] = $post['drillconfig']['comkey']; 59 | $input['width'] = $post['drillconfig']['width']; 60 | $input['height'] = $post['drillconfig']['height']; 61 | // $input['drilllevel'] = $post['drilllevel']; 62 | $input['parenttid'] = $post['tid']; 63 | $input['resizable'] = 0; 64 | //将tconfig存入表中 65 | $tconfig = Db::name('screencharttconfig')->insert($input); 66 | 67 | if(!$tconfig){ 68 | return get_status(1,'添加图表失败',2004); 69 | } 70 | return get_status(0,['tid'=>$input['tid']]); 71 | } 72 | 73 | //修改下钻图表 74 | public function updateDrillchart() 75 | { 76 | $post = input('put.'); 77 | $post['drillconfig']['chartData'] = json_encode($post['drillconfig']['chartData']); 78 | $post['drillconfig']['drilling'] = json_encode($post['drillconfig']['drilling']); 79 | $post['drillconfig']['dataOpt'] = json_encode($post['drillconfig']['dataOpt']); 80 | unset($post['drillconfig']['tid']); 81 | $res = Db::name('screencharttconfig')->where(['tid'=>$post['tid']])->where($post['drillconfig'])->find(); 82 | if($res){ 83 | return get_status(0,'修改成功'); 84 | } 85 | $update = Db::name('screencharttconfig')->where(['tid'=>$post['tid']])->update($post['drillconfig']); 86 | $upScreen['updatetime'] = time(); 87 | $upScreenchart['updatetime'] = time(); 88 | //更新图表更新时间 89 | Db::name('screenchart')->where('tid',$post['tid'])->update($upScreenchart); 90 | //更新大屏更新时间 91 | Db::name('screen')->where('id',$post['screenid'])->update($upScreen); 92 | if($update){ 93 | return get_status(0,'修改成功'); 94 | }else{ 95 | return get_status(1,'图表更新失败',2034); 96 | 97 | } 98 | 99 | } 100 | 101 | //展示下钻图表 102 | public function queryDrillChart() 103 | { 104 | $get = input('get.'); 105 | $res = Db::name('screencharttconfig')->where(['parenttid'=>$get['tid']])->field('id,parenttid,screenid,parenttid,showBorder,chartSourceType,collection,ishide,islock,key,resizable,x,y,selectDaid',true)->find(); 106 | if(!$res){ 107 | return get_status(1,'查询失败',5005); 108 | } 109 | $res['chartData'] = json_decode($res['chartData'],true); 110 | $res['dataOpt'] = json_decode($res['dataOpt'],true); 111 | $res['drilling'] = json_decode($res['drilling'],true); 112 | return get_status(0,['data'=>$res]); 113 | 114 | } 115 | 116 | //删除下钻图表 117 | public function deldrill() 118 | { 119 | $post = input('post.'); 120 | //根据父级tid查找对应的下钻数据 121 | $tid = Db::name('screencharttconfig')->where(['parenttid'=>$post['chid']])->field('tid')->find(); 122 | if(empty($tid)){ 123 | return get_status(1,'暂无下钻图表',7010); 124 | } 125 | //根据下钻tid进行删除下钻图表 126 | $del = Db::name('screencharttconfig')->where($tid)->delete(); 127 | if(!$del){ 128 | return get_status(1,'图表数据删除失败',2005); 129 | } 130 | 131 | $delete = Db::name('screenchart')->where($tid)->delete(); 132 | if(!$delete) { 133 | return get_status(1,'图表删除失败',2005); 134 | }else { 135 | return get_status(0 ,'图表删除成功'); 136 | } 137 | } 138 | 139 | //下钻数据筛选 140 | public function choosedata() 141 | { 142 | $post = [ 143 | 'category'=>'北京', 144 | 145 | ]; 146 | $data = json_decode(file_get_contents('http://192.168.30.119:8099/bingtu/xiazuan/biaozhuduibibingtu.php'),true); 147 | 148 | $data = $data['北京']; 149 | return $data; 150 | 151 | 152 | } 153 | } -------------------------------------------------------------------------------- /application/index/controller/Icon.php: -------------------------------------------------------------------------------- 1 | file('image'); 17 | 18 | if(empty($file)){ 19 | return get_status(1,'图片为空',5002); 20 | } 21 | //定义上传路径 22 | $info = $file->validate(['size'=>1567118])->move(ROOT_PATH . 'public' . DS . 'uploads'. DS . 'Icon'. DS); 23 | //获取路径 24 | $imgSrcWin = str_replace('\\', '/', DS . 'uploads'. DS . 'Icon' . DS . $info->getSaveName()); 25 | 26 | //设置存储路径 27 | $data['iconpath'] = $imgSrcWin; 28 | //设置更改语句 29 | $data = Db::name('icon')->insert($data); 30 | //判断是否更改成功 31 | if($data == null){ 32 | return get_status(1,"上传失败",5004); 33 | }else{ 34 | //查询所有icon地址 35 | $iconlist = Db::name('icon')->select(); 36 | $datas['url'] = $imgSrcWin; 37 | return get_status(0,$datas); 38 | } 39 | } 40 | 41 | //查询icon 42 | public function iconList() 43 | { 44 | $input['pageSize'] = 20; 45 | $input = input('get.'); 46 | if(!isset($input['currentPage'])) { 47 | //查询所有icon地址 48 | $iconlist = Db::name('icon')->select(); 49 | }else { 50 | $iconlist = Db::name('icon')->page($input['currentPage'] ,$input['pageSize'])->select(); 51 | } 52 | $count = Db::name('icon')->count(); 53 | $arr = [ 54 | "list" => $iconlist, 55 | "total" => $count 56 | ]; 57 | return get_status(0,$arr); 58 | } 59 | 60 | //删除icon 61 | public function iconDel() 62 | { 63 | $input = input('delete.'); 64 | //判断input 65 | if(empty($input['upid'])) { 66 | return get_status(1,'参数不能为空' ,5002); 67 | } 68 | 69 | //删除指定icon 70 | $del = Db::name('icon')->delete($input['upid']); 71 | if($del) { 72 | return get_status(0,"删除成功"); 73 | }else { 74 | return get_status(1,"删除失败",5006); 75 | } 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /application/index/controller/Releasebinding.php: -------------------------------------------------------------------------------- 1 | publish = Loader::model('publish'); 14 | } 15 | 16 | /** 17 | * 查询虽有的发布链接以及ID 18 | */ 19 | public function getAllPublish() 20 | { 21 | //获取所有的发布链接及ID 22 | $result = $this->publish->getAllPublish(); 23 | if($result) { 24 | return get_status(0,$result); 25 | }else { 26 | return get_status(1,'查询失败',1111); 27 | } 28 | } 29 | 30 | /** 31 | * 绑定爱创的用户和发布的连接 user 用户标识 linkID 链接 32 | * {"user" : ["token1","token2","token3"],"linkIDs" : 21} 33 | */ 34 | public function BindUserA() 35 | { 36 | $input = input('post.'); 37 | //验证键 38 | $vali = valiKeys(['user','linkID'] , $input); 39 | if($vali['err']) { 40 | return get_status(1,$vali['data'].'键未设置',000); 41 | } 42 | //将user装换为字符串 43 | $input['user'] = implode( ',' , $input['user']); 44 | //验证相同 45 | $result = $this->publish->valiSameBindUser($input); 46 | if($result) { 47 | return get_status(0,'绑定成功'); 48 | } 49 | //将数据用户绑定到数据库 50 | $result = $this->publish->BindUser($input); 51 | //判断绑定是否成功 52 | if($result) { 53 | return get_status(0,'绑定成功'); 54 | }else { 55 | return get_status(1,'绑定失败'); 56 | } 57 | } 58 | 59 | /** 60 | * 绑定爱创的用户和发布的连接 user 用户标识 linkID 链接 61 | * {"user" :"token1","linkID" : 21} 62 | */ 63 | public function BindUsersS() 64 | { 65 | $input = input('post.'); 66 | //验证键 67 | $vali = valiKeys(['user','linkID'] , $input); 68 | if($vali['err']) { 69 | return get_status(1,$vali['data'].'键未设置',000); 70 | } 71 | //获取当前发布链接的ACID 72 | 73 | //将当前ID拼接入原来ACID 74 | 75 | //验证相同 76 | $result = $this->publish->valiSameBindUser($input); 77 | if($result) { 78 | return get_status(0,'绑定成功'); 79 | } 80 | //将数据用户绑定到数据库 81 | $result = $this->publish->BindUser($input); 82 | //判断绑定是否成功 83 | if($result) { 84 | return get_status(0,'绑定成功'); 85 | }else { 86 | return get_status(1,'绑定失败'); 87 | } 88 | } 89 | 90 | 91 | } -------------------------------------------------------------------------------- /application/index/controller/Rep.php: -------------------------------------------------------------------------------- 1 | "biaozhuduibibingtu", 13 | "pie2" => "daitubingtu", 14 | "pie3" => "danzhibaifenbibingtu", 15 | "pie4" => "duoweidubingtu", 16 | "pie5" => "jibenbingtu", 17 | "pie6" => "huanshanbingtu", 18 | "pie7" => "lunbobingtu", 19 | "pie8" => "mubiaozhanbibingtu", 20 | "pie9" => "zhibiaoduibibingtu", 21 | "pie10" => "zhibiaozhanbibingtu", 22 | "pie11" => "huanzhuangfaguangzhanbitu", 23 | "line1" => "daitubingtu", 24 | "line2" => "quyutu", 25 | "line3" => "quyufanpaiqi", 26 | "line4" => "shuangzhouzhexiantu", 27 | "line5" => "3dzhexiantu", 28 | "line6" => "xuxianzhexiantu", 29 | "bar1" => "banmazhutu", 30 | "bar2" => "chuizhijibenzhutu", 31 | "bar3" => "chuizhijiaonanzhutu", 32 | "bar4" => "fenzuzhutu", 33 | "bar5" => "huxingzhutu", 34 | "bar6" => "jibenzhutu", 35 | "bar7" => "shuipingjibenzhutu", 36 | "bar8" => "shuipingjiaonanzhutu", 37 | "bar9" => "tixingzhutu", 38 | "bar10" => "zhexianzhutu", 39 | "bar11" => "danzhouzhexianzhutu", 40 | "bar13" => "shuangxianghengxiangzhuzhuangtu", 41 | "bar14" => "fenzhujianbianzhuzhuangtu", 42 | "bar12" => "3dzhuzhuangtu", 43 | "scatter1" => "qipaotu", 44 | "scatter2" => "sandiantu", 45 | "scatter3" => "sandianzhexiantu", 46 | "scatter4" => "qipaozhexiantu", 47 | "graph" => "guanxiwangluo", 48 | "radar" => "leidatu", 49 | "gauge" => "yibiaopan", 50 | "wordCloud" => "ciyun", 51 | "funnel" => "loudoutu", 52 | "liquidFill" => "shuiqiutu", 53 | "gridheatmap" => "relitu", 54 | "boxplot" => "xiangxingtu", 55 | "hexian" => "hexiantu", 56 | "sunburst" => "xuritu", 57 | "rectangletree" => "juxingshutu", 58 | "sankey" => "sangjitu", 59 | "chinamap" => "zhongguoditu", 60 | "chinamap3d" => "3dzhongguoditu", 61 | "worldMap" => "shijieditu", 62 | "worldMap3d" => "3dshijieditu", 63 | "globechart" => "diqiuyi", 64 | "gismap" => "gismap", 65 | "lunbotable" => "lunbobiaoge", 66 | "txt" => "biaoti", 67 | "time" => "shijian", 68 | "web" => "wangye", 69 | "carousel" => "lunbotu", 70 | "richtxt" => "fuwenben", 71 | "video" => "shipinbofangqi", 72 | "counting" => "jishuban", 73 | "counting2" => "jishuban2", 74 | "txts" => "duoxingwenben", 75 | "diversion" => "paomadeng", 76 | "link" => "chaolianjie", 77 | "progress" => "jindutiao", 78 | "table" => "biaoge", 79 | "circleProgress" => "huanxingjindutiao", 80 | "image" => "tupian", 81 | "icon" => "icon", 82 | "border" => "biankuang", 83 | "linellae" => "xiantiao", 84 | "lines" => "zhixian", 85 | ]; 86 | 87 | public function __construct() 88 | { 89 | $this->screenchartModel = Loader::model("Screenchart"); 90 | } 91 | 92 | public function start() 93 | { 94 | //获取总数 95 | $num = $this->screenchartModel->getCount(); 96 | //分页查询 97 | $p = 10; //每页数 98 | $maxPage = ceil($num / $p);//总页数 99 | //循环取值 100 | for ($i = 1 ; $i <= $maxPage ; $i++) { 101 | //每次10条处理 102 | $this->process($this->screenchartModel->pageSelect($i , $p)); 103 | } 104 | } 105 | 106 | public function process($arr) 107 | { 108 | //遍历数组 109 | foreach ($arr as $value){ 110 | //查找charttype字符串 111 | $charttypeH = substr($value['tconfig'] , strpos( $value['tconfig'], "charttype" )); //截取出现位置以后的 112 | $charttypestring = substr($charttypeH ,0 ,strpos( $charttypeH, '","' )+1); //截取出现未知以前的 113 | //获取charttype图表类型 114 | $charttypeArr = explode(":" , $charttypestring); //将字符串分割成数组 115 | $charttype = str_replace('"' , "" , $charttypeArr[1]); // 去数组后一个 图表类型 116 | if(isset($this->oldNew[$charttype])) { //判断是否在数组中 117 | $charttypeValue = $this->oldNew[$charttype]; //查询新类型 118 | $string = str_replace( $charttype ,$charttypeValue, $charttypestring); //替换 119 | $json = str_replace($charttypestring ,$string , $value); //替换到json 120 | $data[] = ["tconfig" => $json]; //加入到数组 121 | //修改图表 122 | $this->screenchartModel->updateScreenChart($value['tid'] , $json); 123 | } 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /application/index/controller/Socket.php: -------------------------------------------------------------------------------- 1 | ws = new \swoole_websocket_server("0.0.0.0", 9508); 19 | 20 | //初始化socket设置 21 | $this->ws->set([ 22 | 'heartbeat_check_interval' => 20, 23 | 'heartbeat_idle_time' => 45, 24 | ]); 25 | 26 | //初始化缓存 27 | Cache::rm('data'); 28 | } 29 | 30 | //socket主程序 31 | public function socket() 32 | { 33 | //open时处理 34 | $this->socketOpen(); 35 | 36 | //send时处理 37 | $this->socketSend(); 38 | 39 | //关闭连接时处理 40 | $this->socketClose(); 41 | 42 | //回调处理 43 | $this->socketRequest(); 44 | 45 | //开始服务 46 | $this->ws->start(); 47 | 48 | } 49 | 50 | //send时处理 51 | protected function socketOpen() 52 | { 53 | $this->ws->on('open' , function ( \swoole_websocket_server $ws, $request){ 54 | var_dump("客户端-{$request->fd}连接"); 55 | }); 56 | } 57 | 58 | //send时处理 59 | protected function socketSend() 60 | { 61 | $this->ws->on('message', function( \swoole_websocket_server $ws , $request ) { 62 | //接收数据 63 | $json = $request->data; 64 | //检查心跳 65 | if($json == "Are you still alive") { 66 | $ws->push($request->fd, "I am still alive"); 67 | }else { 68 | $type = json_decode($json,1); 69 | if(isset($type['scenesId'])) { 70 | $id = $type['scenesId']; 71 | //存入缓存 72 | $this->saveCache($request->fd, $id); 73 | } 74 | 75 | 76 | } 77 | }); 78 | } 79 | 80 | //关闭是处理 81 | protected function socketClose() 82 | { 83 | $this->ws->on('close',function(\swoole_websocket_server $ws,$request){ 84 | //删除缓存 85 | $this->deleteCache($request); 86 | var_dump("客户端-{$request}断开连接"); 87 | }); 88 | } 89 | 90 | //回调处理 91 | protected function socketRequest() 92 | { 93 | $this->ws->on('Request', function ($req, $respone) { 94 | //接收数据 95 | $data = $req->rawContent(); 96 | $data = json_decode($data,1); 97 | // dump($data); 98 | //写入日志 99 | Log::write($data,'notice'); 100 | // //获取当前在线用户 101 | $fileArr = json_decode(Cache::get('data'),1); 102 | //写入日志 103 | Log::write(json_encode($fileArr),'notice'); 104 | // //判断$fileArr是否为空 105 | if(!empty($fileArr)) { 106 | foreach ($fileArr as $value) { 107 | //遍历改fd的数据 108 | foreach ($data[$value['id']] as $k => $v) { 109 | if(!is_array($v)) { 110 | //将数据保持为数组状态 111 | $data[$value['id']][$k] = json_decode($v,1); 112 | } 113 | } 114 | //推送至客户端保持数据为json 115 | $this->ws->push($value['fd'], json_encode($data[$value['id']])); 116 | } 117 | } 118 | $respone->end("success"); 119 | }); 120 | } 121 | 122 | //存入缓存 123 | protected function saveCache($fd , $json) 124 | { 125 | //查看缓存 126 | $cache = Cache::get('data'); 127 | if($cache != '') { 128 | //将json转换为数组 129 | $cacheArr = json_decode($cache,1); 130 | $data = ['fd' => $fd , 'id' => $json]; 131 | //将本次连接记录 132 | $cacheArr[$fd] = $data; 133 | //数组转换为json方便存储 134 | $json = json_encode($cacheArr); 135 | }else { 136 | $cacheArr[$fd] = ['fd' => $fd , 'id' => $json]; 137 | $json = json_encode($cacheArr); 138 | } 139 | //将json存储缓存 140 | Cache::set('data', $json); 141 | } 142 | 143 | //删除缓存 144 | protected function deleteCache($fd) 145 | { 146 | //查看缓存 147 | $cache = Cache::get('data'); 148 | if($cache) { 149 | //将json转换为数组 150 | $cacheArr = json_decode($cache,1); 151 | //删除对应数据 152 | unset($cacheArr[$fd]); 153 | //判断是否还有连接 154 | if(empty($cacheArr)) { 155 | //没有连接初始化缓存 156 | Cache::rm('data'); 157 | }else { 158 | //数组转换为json方便存储 159 | $json = json_encode($cacheArr); 160 | //将剩余json化存储缓存 161 | Cache::set('data', $json); 162 | } 163 | }else { 164 | return; 165 | } 166 | } 167 | 168 | 169 | } -------------------------------------------------------------------------------- /application/index/controller/Socketscreen.php: -------------------------------------------------------------------------------- 1 | ws) { 18 | //实例化swoole对象 19 | $this->ws = new \swoole_websocket_server("0.0.0.0", 9577); 20 | //初始化缓存 21 | Cache::rm('screen'); 22 | } 23 | } 24 | 25 | //socket主程序 26 | public function socket() 27 | { 28 | //open时处理 29 | $this->socketOpen(); 30 | 31 | //send时处理 32 | $this->socketSend(); 33 | 34 | //关闭连接时处理 35 | $this->socketClose(); 36 | 37 | //回调处理 38 | $this->socketRequest(); 39 | 40 | //开始服务 41 | $this->ws->start(); 42 | 43 | } 44 | 45 | //send时处理 46 | protected function socketOpen() 47 | { 48 | $this->ws->on('open' , function ( \swoole_websocket_server $ws, $request){ 49 | var_dump("客户端-{$request->fd}连接"); 50 | }); 51 | } 52 | 53 | //send时处理 54 | protected function socketSend() 55 | { 56 | $this->ws->on('message', function( \swoole_websocket_server $ws , $request ) { 57 | //接收数据 58 | $json = $request->data; 59 | if($json == "heartbeat") { 60 | $ws->push($request->fd, "I am still alive"); 61 | }else { 62 | $json = json_decode($json,1); 63 | //存入缓存 64 | $this->saveCache($request->fd, $json['sid']); 65 | } 66 | }); 67 | } 68 | 69 | //关闭是处理 70 | protected function socketClose() 71 | { 72 | $this->ws->on('close',function(\swoole_websocket_server $ws,$request){ 73 | //删除缓存 74 | $this->deleteCache($request); 75 | var_dump("客户端-{$request}断开连接"); 76 | }); 77 | } 78 | 79 | //回调处理 80 | protected function socketRequest() 81 | { 82 | $this->ws->on('Request', function ($req, $respone) { 83 | //接收数据 84 | $data = $req->rawContent(); 85 | //写入日志 86 | Log::write($data,'notice'); 87 | //反序列化 88 | $data = json_decode($data,1); 89 | dump($data); 90 | // //获取当前在线用户 91 | $fileArr = json_decode(Cache::get('screen'),1); 92 | //写入日志 93 | Log::write(json_encode($fileArr),'notice'); 94 | dump($fileArr); 95 | // //判断$fileArr是否为空 96 | if(!empty($fileArr)) { 97 | foreach ($fileArr as $value) { 98 | $this->ws->push($value['fd'], $data[$value['sid']]); 99 | // $this->ws->push(1, "大屏"); 100 | } 101 | } 102 | $respone->end("success"); 103 | 104 | }); 105 | } 106 | 107 | //存入缓存 108 | protected function saveCache($fd , $sid) 109 | { 110 | //查看缓存 111 | $cache = Cache::get('screen'); 112 | if($cache != '') { 113 | //将json转换为数组 114 | $cacheArr = json_decode($cache,1); 115 | $data = ['fd' => $fd , 'sid' => $sid]; 116 | //将本次连接记录 117 | $cacheArr[$fd] = $data; 118 | //数组转换为json方便存储 119 | $json = json_encode($cacheArr); 120 | }else { 121 | $cacheArr[$fd] = ['fd' => $fd , 'sid' => $sid]; 122 | $json = json_encode($cacheArr); 123 | } 124 | //将json存储缓存 125 | Cache::set('screen', $json); 126 | } 127 | 128 | //删除缓存 129 | protected function deleteCache($fd) 130 | { 131 | //查看缓存 132 | $cache = Cache::get('screen'); 133 | if($cache) { 134 | //将json转换为数组 135 | $cacheArr = json_decode($cache,1); 136 | //删除对应数据 137 | unset($cacheArr[$fd]); 138 | //判断是否还有连接 139 | if(empty($cacheArr)) { 140 | //没有连接初始化缓存 141 | Cache::rm('screen'); 142 | }else { 143 | //数组转换为json方便存储 144 | $json = json_encode($cacheArr); 145 | //将剩余json化存储缓存 146 | Cache::set('screen', $json); 147 | } 148 | }else { 149 | return; 150 | } 151 | } 152 | 153 | 154 | } -------------------------------------------------------------------------------- /application/index/controller/System.php: -------------------------------------------------------------------------------- 1 | where('username',$username)->find(); 29 | 30 | //判断原始密码是否正确 31 | if($oldPassword != $passData['password']){ 32 | get_Log($username,'修改密码_旧密码错误','失败'); 33 | $data = get_status(1,2400,NULL); 34 | return $data; 35 | } 36 | //判断新密码是否与旧密码相同 37 | if($newPassword === $passData['password']){ 38 | get_Log($username,'修改密码_新旧密码相同','失败'); 39 | $data = get_status(1,2401,NULL); 40 | return $data; 41 | } 42 | //执行更新语句 43 | $udata['password'] = $newPassword; 44 | 45 | $change = Db::name('user')->where('username',$username)->update($udata); 46 | 47 | //判断是否更新成功 48 | if(empty($change)){ 49 | get_Log($username,'修改密码_更改密码执行sql','失败'); 50 | $data = get_status(1,NULL,NULL); 51 | return $data; 52 | }else{ 53 | get_Log($username,'修改密码_更改密码','成功'); 54 | $data = get_status(0,NULL,NULL); 55 | return $data; 56 | } 57 | 58 | } 59 | 60 | //修改用户名 changeUsername 61 | public function changeUsername() 62 | { 63 | //post接收来的数据 64 | $dataPost = file_get_contents('php://input'); 65 | $type =json_decode($dataPost,1); 66 | 67 | 68 | $username = $type['username']; 69 | $newUsername = $type['newusername']; 70 | $Password = md5($type['password']); 71 | if($username === $newUsername){ 72 | return get_status(1,NULL,NULL); 73 | } 74 | $data = Db::name('user')->where('username',$username)->find(); 75 | 76 | if($Password != $data['password']){ 77 | return get_status(1,NULL,NULL); 78 | } 79 | 80 | $return = Db::name('user')->where('username',$username)->update(['username'=>$newUsername]); 81 | 82 | 83 | 84 | if(empty($change)){ 85 | return get_status(0,NULL,NULL); 86 | }else{ 87 | return get_status(1,NULL,NULL); 88 | } 89 | 90 | } 91 | //服务器地址修改 92 | public function updateIp() 93 | { 94 | //post接收来的数据 95 | $dataPost = file_get_contents('php://input'); 96 | $type =json_decode($dataPost,1); 97 | 98 | $ip = $typr['ip']; 99 | 100 | $update = Db::name('system')->where('id','1')->update($ip); 101 | return $data['err'] = '0'; 102 | } 103 | 104 | //获取用户列表 105 | public function getUser() 106 | { 107 | $data = Db::name('user')->field('username,power')->select(); 108 | 109 | return get_status(0,0,$data); 110 | 111 | } 112 | //删除用户 113 | public function deleteUser() 114 | { 115 | //接收post来的数据 116 | $dataPost = file_get_contents('php://input'); 117 | //POST来的数据转换成json格式 118 | $post =json_decode($dataPost,1); 119 | //获取用户名 120 | $user = $post['user']; 121 | //获取删除用户名 122 | $username = $post['username']; 123 | //获取超级管理员密码 124 | $password = md5($post['password']); 125 | //判断操作用户是否为超级管理员 126 | if($user != 'admin'){ 127 | return get_status(1,0,NULL); 128 | } 129 | //验证超级管理员密码 130 | $Dbpassword = Db::name('user')->where('username', $user)->field('password')->find(); 131 | if($Dbpassword != $password){ 132 | return get_status(1,0,NULL); 133 | } 134 | 135 | //执行删除 136 | $delete = Db::name('user')->where('username',$username)->delete(); 137 | $DbUser = Db::name('user')->field('username')->select(); 138 | 139 | //返回删除后user列表 140 | return get_status(0,0,$DbUser); 141 | } 142 | 143 | //注册用户 144 | public function register() 145 | { 146 | //接收post来的数据 147 | $dataPost = file_get_contents('php://input'); 148 | //POST来的数据转换成json格式 149 | $post =json_decode($dataPost,1); 150 | //获取注册用户名 151 | $username = $post['username']; 152 | //获取注册用户的密码 153 | $password = md5($post['password']); 154 | //获取注册用户的重复密码 155 | $repassword = md5($post['repassword']); 156 | //获取注册用户的权限 157 | $power = $post['power']; 158 | //获取操作用户的用户名 159 | $user = $post['user']; 160 | //获取操作用户的密码 161 | $pass = $post['pass']; 162 | //验证操作用户身份 163 | if($user != 'admin'){ 164 | return get_status(1,0,NULL); 165 | } 166 | //验证注册用户的两次密码是否相同 167 | if($password != $repassword){ 168 | return get_status(1,0,NULL); 169 | } 170 | //验证用户名是否存在 171 | $Dbusername = Db::name('user')->where('username',$username)->find(); 172 | if(!empty($Dnusername)){ 173 | return get_status(1,0,NULL); 174 | } 175 | //执行添加语句 176 | $insertData['username'] = $username; 177 | $insertData['password'] = $password; 178 | $insertData['power'] = $power; 179 | $insert = Db::name('user')->insert($insertData); 180 | //查询数据表 181 | $data = Db::name('user')->select(); 182 | 183 | //返回数据列表 184 | return get_status(0,0,$data); 185 | 186 | } 187 | //获取日志 188 | public function getLog() 189 | { 190 | $data = Db::name('log')->select(); 191 | 192 | return get_status(0,0,$data); 193 | } 194 | //获取权限列表 195 | public function power() 196 | { 197 | $data = Db::name('power')->select(); 198 | 199 | return get_status(0,0,$data); 200 | 201 | } 202 | 203 | 204 | 205 | } 206 | -------------------------------------------------------------------------------- /application/index/controller/Test.php: -------------------------------------------------------------------------------- 1 | '\think\oracle\Connection', 20 | // 服务器地址 21 | 'hostname' => '192.168.30.189', 22 | // 数据库名 23 | 'database' => 'sdata', 24 | //用户名 25 | 'username' => 'root', 26 | // 密码 27 | 'password' => 'liwenkaihaha', 28 | // 端口 29 | 'hostport' => '', 30 | // 连接dsn 31 | 'dsn' => '', 32 | // 数据库连接参数 33 | 'params' => [], 34 | // 数据库编码默认采用utf8 35 | 'charset' => 'utf8', 36 | // 数据库表前缀 37 | 'prefix' => 'sdata_', 38 | // 数据库调试模式 39 | 'debug' => true, 40 | // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 41 | 'deploy' => 0, 42 | // 数据库读写是否分离 主从式有效 43 | 'rw_separate' => false, 44 | // 读写分离后 主服务器数量 45 | 'master_num' => 1, 46 | // 指定从服务器序号 47 | 'slave_no' => '', 48 | // 是否严格检查字段是否存在 49 | 'fields_strict' => true, 50 | // 数据集返回类型 51 | 'resultset_type' => 'array', 52 | // 自动写入时间戳字段 53 | 'auto_timestamp' => false, 54 | // 时间字段取出后的默认时间格式 55 | 'datetime_format' => 'Y-m-d H:i:s', 56 | // 是否需要进行SQL性能分析 57 | 'sql_explain' => false, 58 | ]; 59 | //$db = new \think\db\connector\Oracle; 60 | $db = Db::connect($database)->name('users')->select(); 61 | dump($db); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /application/index/controller/Websocket.php: -------------------------------------------------------------------------------- 1 | screen)) { 19 | $this->screen = new Screen(); 20 | } 21 | } 22 | //主程序 23 | public function index() 24 | { 25 | $input = input('get.'); 26 | //判断数据是否接收成功 27 | if(!$input) { 28 | return get_status(1,'数据接收失败',000); 29 | } 30 | $id = intval($input['id']); 31 | //通过ID找到大屏对应的图表 32 | // $charts = Db::name('screenchart')->where('screenid', $id)->field('tid,tconfig')->select(); 33 | $charts = Db::name('screenchart')->field('screencharttconfig.dataOpt,screenchart.tid')->alias('screenchart')->join('screencharttconfig','screenchart.tid=screencharttconfig.tid')->where('screenchart.screenid', $id)->select(); 34 | //判断charts是否为空 35 | if(empty($charts)) { 36 | return get_status(0,[]); 37 | } 38 | //将自动刷新的图表ID提取出来 39 | $autoChart = $this->getAutoChart($charts); 40 | //判断autoChartID是否为空 41 | if(empty($autoChart)) { 42 | return get_status(0,[]); 43 | } 44 | //处理自动刷新获取返回值 45 | $autuResult = $this->autoChart($autoChart); 46 | //直接返回数据无需判断 47 | return get_status(0,$autuResult); 48 | } 49 | 50 | /** 51 | * 提取自动刷新图表 52 | */ 53 | protected function getAutoChart( array $charts) 54 | { 55 | //声明自动刷新图表ID集合数组 56 | $autu = []; 57 | $i = 0; 58 | //遍历图表数组 59 | foreach($charts as $key => $value) { 60 | //反序列化config 61 | // $config = json_decode($value['tconfig'],1); 62 | $value['dataOpt'] = json_decode($value['dataOpt'],1); 63 | if( isset($value['dataOpt']['source']['type']) && isset($value['dataOpt']['autoUpdate'])) { 64 | //拿到是否自动刷新字段 65 | $isAotu = $value['dataOpt']['autoUpdate']; 66 | //数据源类型部位websocket 67 | $type = $value['dataOpt']['source']['type']; 68 | //判断是否自动刷新 69 | if($isAotu && strtolower($type != 'websocket')) { 70 | //将自动刷新图表ID传入 71 | $autu[$i]['tid'] = $value['tid']; 72 | //自动刷新开始时间 73 | $autu[$i]['autoupdatetime'] = $value['dataOpt']['clockStart']; 74 | //自动刷新秒数 75 | $autu[$i]['timeClock'] = $value['dataOpt']['timeClock']; 76 | $i++; 77 | } 78 | } 79 | } 80 | //返回自动刷新图表ID集合 81 | return $autu; 82 | } 83 | 84 | /** 85 | * 处理自动刷新 86 | * */ 87 | protected function autoChart( array $autoChart) 88 | { 89 | //声明自动刷新图表数据 90 | $autuChartData = []; 91 | //遍历自动刷新数组 92 | foreach($autoChart as $key => $value) { 93 | //计算出当前时间与自动刷新开始时间差 94 | $chartDiff = intval(time() - $value['autoupdatetime']); 95 | //判断是否符合自动刷新时间 96 | if ($chartDiff % $value['timeClock'] == 0) { 97 | //执行图表数据获取方法 98 | $result = $this->screen->getAllChart(['chartid' => $value['tid']]); 99 | //提取返回数组中的图表名称及相对应的value 100 | foreach ($result['data'] as $k => $v) { 101 | //判断是否有数据 102 | if(!empty($v)) { 103 | //获取图表数据 104 | $autuChartData[$k] = $v; 105 | } 106 | 107 | } 108 | } 109 | } 110 | //返回图表数据集合 111 | return $autuChartData; 112 | } 113 | 114 | 115 | } -------------------------------------------------------------------------------- /application/index/model/Carousel.php: -------------------------------------------------------------------------------- 1 | table)->insertGetId($data); 43 | } 44 | 45 | //修改信息 46 | public function updateCarousel($data , $where) 47 | { 48 | if(empty($data['animation'])){ 49 | return false; 50 | } 51 | if(empty($data['cname'])){ 52 | return false; 53 | } 54 | if(empty($data['controlPos'])){ 55 | return false; 56 | } 57 | if(empty($data['crIdent'])){ 58 | return false; 59 | } 60 | if(empty($data['crLink'])){ 61 | return false; 62 | } 63 | if(empty($data['createtime'])){ 64 | return false; 65 | } 66 | if(empty($data['remarks'])){ 67 | return false; 68 | } 69 | if(empty($data['screens'])){ 70 | return false; 71 | } 72 | if(empty($data['time'])){ 73 | return false; 74 | } 75 | if(empty($data['updatetime'])){ 76 | return false; 77 | } 78 | return Db::name($this->table)->where($where)->update($data); 79 | } 80 | 81 | //通过条件获取详情信息列表 82 | public function getCarouselList($where) 83 | { 84 | return Db::name($this->table)->where($where)->find(); 85 | } 86 | 87 | //获取全部详情信息列表 88 | public function getCarouselListAll($where = null,$currentPage = null,$pageSize = null,$order = null) 89 | { 90 | return Db::name($this->table)->order($order,'desc')->where('cname','like','%'.$where.'%')->page($currentPage,$pageSize)->select(); 91 | } 92 | 93 | public function deleteCarousel($where) 94 | { 95 | return Db::name($this->table)->where($where)->delete(); 96 | 97 | } 98 | } -------------------------------------------------------------------------------- /application/index/model/Deviceinfo.php: -------------------------------------------------------------------------------- 1 | table)->where($data)->find(); 22 | } 23 | 24 | /** 25 | * 将绑定数据信息插入数据库 26 | * @param $data 27 | * @return bool 28 | */ 29 | public function bindDevice($data) 30 | { 31 | //绑定信息存入数据库 32 | return Db::name($this->table)->where("scenes" , $data['scenes'])->insert($data); 33 | } 34 | 35 | 36 | 37 | 38 | } -------------------------------------------------------------------------------- /application/index/model/Gisdata.php: -------------------------------------------------------------------------------- 1 | table)->where('gistype' , 'in' , $where)->column('gisdata','gistype'); 19 | } 20 | } -------------------------------------------------------------------------------- /application/index/model/My.php: -------------------------------------------------------------------------------- 1 | table)->field('pid,sname,link')->select(); 24 | } 25 | 26 | /**将发布绑定用于用户验证 27 | * @param $data 28 | * @return bool 29 | * @throws \think\Exception 30 | * @throws \think\exception\PDOException 31 | */ 32 | public function BindUser($data) 33 | { 34 | return Db::name($this->table)->where('pid',$data['linkID'])->update(['acid' => $data['user']]); 35 | } 36 | 37 | /**验证相同 38 | * @param $data 39 | * @return bool 40 | * @throws \think\db\exception\DataNotFoundException 41 | * @throws \think\db\exception\ModelNotFoundException 42 | * @throws \think\exception\DbException 43 | */ 44 | public function valiSameBindUser($data) 45 | { 46 | return Db::name($this->table)->where(['acid' => $data['user'] , 'pid' => $data['linkID']])->find(); 47 | } 48 | 49 | public function getWhereList($where ,$field = "*") 50 | { 51 | return Db::name($this->table)->where($where)->field($field)->select(); 52 | } 53 | } -------------------------------------------------------------------------------- /application/index/model/Screen.php: -------------------------------------------------------------------------------- 1 | table)->where("id" , $id)->field("data,name,lock,screentype,ratio,pixel")->find(); 23 | } 24 | 25 | //查询模板列表 26 | public function templateSummary($where,$order,$currentPage,$pageSize,$like) 27 | { 28 | //查询自定义模板 29 | // if($where['tempcate'] == 1){ 30 | // $data = Screen::where($where)-> 31 | // where('name','like','%'.$like.'%')-> 32 | // order($order,'DESC')-> 33 | // page($currentPage,$pageSize)-> 34 | // field('id,name,screenid,imgdata,publishuser,share')-> 35 | // select(); 36 | // $total = Screen::where($where)->where('name','like','%'.$like.'%')->count(); 37 | 38 | // }else{ 39 | // //查询通用模板列表 40 | // $data = Screen::where('tempcate=1 AND share=1')-> 41 | // whereOr('tempcate',0)-> 42 | // where('screentype',2)-> 43 | // where('name','like','%'.$like.'%')-> 44 | // order($order,'DESC')-> 45 | // page($currentPage,$pageSize)-> 46 | // field('id,name,screenid,imgdata,publishuser,share')-> 47 | // select(); 48 | // //查询列表总数 49 | // $total = Screen::where('tempcate=1 AND share=1')->whereOr('tempcate',0)->where('screentype',2)->where('name','like','%'.$like.'%')->count(); 50 | // } 51 | $data = Screen::where($where)-> 52 | where('name','like','%'.$like.'%')-> 53 | order($order,'DESC')-> 54 | page($currentPage,$pageSize)-> 55 | field('id,name,screen_sid,ratio,pixel,imgdata,publishuser,share')-> 56 | select(); 57 | $total = Screen::where($where)->where('name','like','%'.$like.'%')->count(); 58 | 59 | $data = ['list'=>$data,'total'=>$total]; 60 | return $data; 61 | } 62 | 63 | //对默认模板进行软删除 64 | public function softdel($id) 65 | { 66 | //进行软删除 67 | $del = Screen::destroy($id); 68 | if($del){ 69 | return $del; 70 | } 71 | } 72 | 73 | //恢复默认模版 74 | public function recsof() 75 | { 76 | $id = []; 77 | //查询软删除的模版 78 | $del = Screen::onlyTrashed()->select(); 79 | if(empty($del)){ 80 | return true; 81 | } 82 | foreach($del as $k=>$v){ 83 | $id[] = $v['id']; 84 | } 85 | foreach($id as $key=>$val){ 86 | //查询要恢复的模版 87 | $del = Screen::onlyTrashed()->find($val); 88 | //进行恢复 89 | $del->restore(); 90 | } 91 | return true; 92 | 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /application/index/model/Screenchart.php: -------------------------------------------------------------------------------- 1 | table)->select(); 20 | } 21 | 22 | //获取总数 23 | public function getCount() 24 | { 25 | return Db::name($this->table)->count(); 26 | } 27 | 28 | //分页查询 29 | 30 | public function pageSelect( $p , $pageNum) 31 | { 32 | return Db::name($this->table)->field("tid,tconfig")->page($p,$pageNum)->select(); 33 | } 34 | 35 | public function updateScreenChart($id, $data) 36 | { 37 | return Db::name($this->table)->where("tid",$id)->update($data); 38 | } 39 | 40 | //获取指定大屏下的所有图表 41 | public function getScreenList($id) 42 | { 43 | return Db::name($this->table)->where("screenid" , $id)->field("tid,screenid,talias,tname,tdata,islock, 44 | link,collection,ishide,autoupdatetime,daid")->select(); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /application/index/model/Unity.php: -------------------------------------------------------------------------------- 1 | table)->select(); 25 | } 26 | 27 | public function deleteScenes($id) 28 | { 29 | return Db::name($this->table)->where('jsonid' , $id)->delete(); 30 | } 31 | 32 | /** 33 | * 查询所有的设备 34 | */ 35 | public function getAllDevice() 36 | { 37 | return Db::name($this->table)->select(); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /application/index/model/User.php: -------------------------------------------------------------------------------- 1 | select(); 13 | } 14 | 15 | //获取所有的权限 16 | public function permission() 17 | { 18 | return Db::name('permission')->select(); 19 | } 20 | 21 | //获取角色的名字 $rid 角色ID 22 | public function getRolename($rid) 23 | { 24 | return Db::name('role')->where(['rid' =>$rid])->find(); 25 | } 26 | 27 | //获取角色ID $uid 用户ID 28 | public function getRole($uid) 29 | { 30 | return Db::name('user_role')->where(['uid' => $uid])->find(); 31 | } 32 | 33 | //获取登录用户信息 $uid 用户ID 34 | public function getUser($uid) 35 | { 36 | return Db::name('user')->where(['uid' => $uid])->find(); 37 | } 38 | 39 | //获取权限ID $rid 角色ID 40 | public function getPid($rid) 41 | { 42 | return Db::name('role_permission')->where(['rid' => $rid])->find(); 43 | } 44 | 45 | //获取权限列表 $pid 权限ID 字符串 46 | public function getPermission($pid) 47 | { 48 | return Db::name('permission')->order('pid', 'asc')->select($pid); 49 | } 50 | 51 | //删除用户 $table 表名 $uid 用户ID 52 | public function del($table , $uid) 53 | { 54 | if($uid == 1) { 55 | return false; 56 | } 57 | return Db::name($table)->delete($uid); 58 | } 59 | 60 | 61 | //修改用户 $table 表名 $data 数据信息 $uid 用户ID 62 | public function userUpdate($table, $uid ,$data ) 63 | { 64 | return Db::name($table)->where(['uid' => $uid])->update($data); 65 | } 66 | 67 | //增加用户 $table 表名 $data 数据信息 68 | public function userAdd($table , $data) 69 | { 70 | return Db::name($table)->insert($data); 71 | } 72 | 73 | //查询信息 $table 表名 , $where 条件 数组or字符串 74 | public function getMessg($table,$where = null,$id = null , $page = "1,99999") 75 | { 76 | return Db::name($table)->where($where)->page($page)->select($id); 77 | } 78 | 79 | //查询信息 $table 表名 , $where 条件 数组or字符串 80 | public function updateMessg($table,$where,$data) 81 | { 82 | return Db::name($table)->where($where)->update($data); 83 | } 84 | 85 | //删除信息 $table 表名 , $where 条件 数组or字符串 86 | public function deleteMessg($table,$where) 87 | { 88 | return Db::name($table)->where($where)->delete(); 89 | } 90 | 91 | //查询列信息 $table 表名 , $where 条件 数组or字符串 92 | public function getColumn($table,$where = null , $column = null) 93 | { 94 | return Db::name($table)->where($where)->value($column); 95 | } 96 | 97 | //SQL查询 98 | public function sqlExec($sql) 99 | { 100 | return Db::query($sql); 101 | } 102 | 103 | 104 | //增加用户 return 自增ID 105 | public function messageAdd($table,$data) 106 | { 107 | return Db::name($table)->insertGetId($data); 108 | } 109 | 110 | //查询字段 table 表名 where 条件 field 字段名 111 | public function getField($table,$where = null ,$field, $id = null ,$page = "0,99999" , $order = null ) 112 | { 113 | return Db::name($table)->where($where)->field($field)->page($page)->order($order)->select($id); 114 | } 115 | 116 | //模糊查询 table 表名 field 字段名(str) value条件(str) 117 | public function messageLike($table , $field , $value) 118 | { 119 | return Db::name($table)->where($field , 'like' , '%'.$value.'%')->select(); 120 | } 121 | 122 | //计算总数 123 | public function countNember($table , $id) 124 | { 125 | return Db::name($table)->count($id); 126 | } 127 | 128 | 129 | } -------------------------------------------------------------------------------- /application/index/model/sdata.php: -------------------------------------------------------------------------------- 1 | query('show measurements'); 20 | dump($result); 21 | } 22 | 23 | public function demo() 24 | { 25 | $file = ROOT_PATH . 'plugins' . DS . 'demo2.zip'; 26 | // $zip = new \ZipArchive; 27 | // $open = $zip->open($file); 28 | $zip = zip_open($file); 29 | $zip = zip_read($file); 30 | dump($zip); 31 | // dump($zip);die; 32 | // if ($zip->open($file) === TRUE) { 33 | // for ($idx=0 ; $s = $zip->statIndex($idx) ; $idx++) { 34 | // dump($zip->getExternalAttributesIndex($idx)); 35 | // // if ($zip->extractTo('.', $s['name'])) { 36 | // // if ($zip->getExternalAttributesIndex($idx, $opsys, $attr) 37 | // // && $opsys==ZipArchive::OPSYS_UNIX) { 38 | // // chmod($s['name'], ($attr & 07777)); 39 | // // } 40 | // // } 41 | // } 42 | // // $zip->extractTo($this->pluginDir); 43 | // $zip->close(); 44 | // return true; 45 | // } else { 46 | // return false; 47 | // } 48 | } 49 | } -------------------------------------------------------------------------------- /application/plugins/controller/Index.php: -------------------------------------------------------------------------------- 1 | where($where)->count(); 35 | $result = $plugin->where($where)->order("$sortField desc")->page($page)->limit($limit)->select(); 36 | $return_data['sum_count'] = $sum_count; 37 | $return_data['result'] = $result; 38 | return get_status(0 , $return_data); 39 | } 40 | 41 | /** 42 | * 批量删除插件 43 | * 44 | * @param Plugins $plugin 45 | * @return void 46 | */ 47 | public function del(Plugins $plugin) 48 | { 49 | $ids = input('post.pluginIds/a'); 50 | $info = $plugin->where('id', 'in', $ids)->select(); 51 | if (!$info) return get_status(1 , '找不到插件信息'); 52 | $result = $plugin->where('id', 'in', $ids)->delete(); 53 | if (!$result) { 54 | return get_status(1 , '卸载失败'); 55 | } 56 | foreach ($info as $value) { 57 | removeDir(self::$pluginDir . $value['dir']); 58 | } 59 | return get_status(0 , '已卸载'); 60 | } 61 | 62 | public static function upSinglePlugin($path) 63 | { 64 | $dir = basename($path); 65 | self::$upSingleDir = $dir; 66 | return self::update(); 67 | } 68 | 69 | /** 70 | * 扫描插件目录 71 | * 72 | * @return void 73 | */ 74 | public static function update() 75 | { 76 | $dirs = self::scan(); 77 | $plugins = []; 78 | foreach ($dirs as $dir) { 79 | if ($dir == '.' || $dir == '..' || $dir == '.gitignore') continue; 80 | $pluginPath = self::$pluginDir . $dir; 81 | if (is_file($pluginPath)) continue; 82 | if (self::$upSingleDir && $dir != self::$upSingleDir) continue; 83 | $data['pluginPath'] = self::$pluginRelativePath . $dir; 84 | $data['xmlPath'] = $pluginPath . DS . 'plugin.xml'; 85 | $data['info'] = self::getXml($data['xmlPath']); 86 | $data['name'] = $data['info']['moduleId']; 87 | $data['dir'] = $dir; 88 | $data['version'] = $data['info']['moduleVersion']; 89 | $data['type'] = $data['info']['moduleType'] ?? 'chart'; 90 | 91 | $result = self::savePlugin($data); 92 | //静态数据 93 | $TestData = $pluginPath . DS . $data['info']['moduleTestData']; 94 | $TestData = file_get_contents($TestData); 95 | self::saveChartdata($TestData,$data['info']['moduleId']); 96 | 97 | $plugins[$dir]['result'] = true; 98 | $plugins[$dir]['msg'] = 'ok'; 99 | if (!$result) { 100 | $plugins[$dir]['result'] = false; 101 | $plugins[$dir]['msg'] = '写入失败'; 102 | } 103 | if ($result === -1) { 104 | $plugins[$dir]['result'] = false; 105 | $plugins[$dir]['msg'] = '插件版本已存在'; 106 | } 107 | $plugins[$dir]['name'] = $data['name']; 108 | } 109 | return get_status(0 , $plugins); 110 | } 111 | 112 | /** 113 | * 保存入库 114 | * 115 | * @param [type] $plugin 116 | * @return void 117 | */ 118 | public static function savePlugin($plugin) 119 | { 120 | $time = time(); 121 | $plugin['info'] = json_encode($plugin['info'], JSON_UNESCAPED_UNICODE); 122 | $plugin['update_time'] = date('Y-m-d H:i:s', $time); 123 | $data = new Plugins(); 124 | $findPlugin = $data->where(['name' => $plugin['name']])->find(); 125 | if ($findPlugin) { 126 | // if ($findPlugin['version'] == $plugin['version']) return -1; 127 | return $data->allowField(true)->save($plugin, ['id' => $findPlugin['id']]); 128 | } 129 | $plugin['create_time'] = $plugin['update_time']; 130 | return $data->allowField(true)->save($plugin); 131 | } 132 | public static function saveChartdata($data,$charttype) 133 | { 134 | $result = Db::table('up_chartdata')->where('charttype',$charttype)->find(); 135 | if(empty($result)){ 136 | //添加操作 137 | $data = ['data' => $data, 'charttype' => $charttype]; 138 | Db::table('up_chartdata')->insert($data); 139 | }else{ 140 | //修改操作 141 | Db::table('up_chartdata')->where('charttype', $charttype)->update(['data' =>$data]); 142 | 143 | } 144 | } 145 | 146 | public static function scan() 147 | { 148 | //扫描文件夹 149 | return scandir(self::$pluginDir); 150 | } 151 | 152 | /** 153 | * 由路径解析xml 154 | * 155 | * @param [type] $xmlPath 156 | * @return void 157 | */ 158 | public static function getXml($xmlPath) 159 | { 160 | $json = json_encode((array) simplexml_load_file($xmlPath), JSON_UNESCAPED_UNICODE); 161 | $info = str_replace('{}', '""', $json); 162 | $info = str_replace(array('\n\t'), "", $info); 163 | // dump($info);die; 164 | $result = json_decode($info, true); 165 | return $result; 166 | // dump($result);die; 167 | // $modifyData = self::modifyDataType($result); 168 | // dump($modifyData);die; 169 | } 170 | 171 | // protected static function modifyDataType( $data) 172 | // { 173 | // foreach ($data as $key => $value) { 174 | // if (is_array($value)) { 175 | // $data[$key] = self::modifyDataType($value); 176 | // } else { 177 | // if (in_array($key, self::$xmlDataType)) { 178 | // $data[$key] = self::getType($key, $value); 179 | // } 180 | // } 181 | // } 182 | // return $data; 183 | // } 184 | 185 | // protected static function getType($type, $value) 186 | // { 187 | // switch ($type) { 188 | // case 'boolean': 189 | // return ($value == 'true') ? true : false; 190 | // case 'int': 191 | // return (int) $value; 192 | // case 'float': 193 | // return (float) $value; 194 | // default: 195 | // return ''; 196 | // } 197 | // } 198 | } -------------------------------------------------------------------------------- /application/plugins/controller/Upload.php: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 | 25 | '; 26 | } 27 | 28 | /** 29 | * 从链接上传插件 30 | * 31 | * @return void 32 | */ 33 | public function url() 34 | { 35 | $url = input('get.url'); 36 | if (!$this->checkUrl($url)) { 37 | return get_status(1 , '插件地址不正确!'); 38 | } 39 | $fileInfo = pathinfo($url); 40 | $fileName = $fileInfo['basename']; 41 | $extension = $fileInfo['extension']; 42 | $savePath = $this->pluginDir . DS . $fileName; 43 | if (!in_array($extension, explode(',', $this->ext))) { 44 | return get_status(1 , '文件格式错误'); 45 | } 46 | ob_start(); 47 | readfile($url); 48 | $file = ob_get_contents(); 49 | ob_end_clean(); //清除输出并关闭 50 | file_put_contents($savePath, $file); 51 | $result = $this->decompression($savePath, $extension,$fileName); 52 | @unlink($savePath); 53 | if (!$result) return get_status(1 , '失败'); 54 | return get_status(0 , 'ok'); 55 | } 56 | 57 | /** 58 | * 本地上传 59 | * 60 | * @return void 61 | */ 62 | public function index() 63 | { 64 | // 获取表单上传文件 例如上传了001.jpg 65 | $file = request()->file('file'); 66 | // 验证文件 67 | if($file){ 68 | $info = $file->validate(['size' => $this->size,'ext' => $this->ext])->move($this->pluginDir, '', false); 69 | if($info){ 70 | // 成功上传后 获取上传信息 71 | // 输出 jpg 72 | $extension = $info->getExtension(); 73 | // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg 74 | $filePath = $this->pluginDir . DS . $info->getSaveName(); 75 | $result = $this->decompression($filePath, $extension,$info->getSaveName()); 76 | 77 | @unlink($filePath); 78 | if (!$result) return get_status(1 , '失败'); 79 | // $result为路径 80 | return \app\plugins\controller\Index::upSinglePlugin($result); 81 | // 输出 42a79759f284b767dfcb2a0197904287.jpg 82 | // $fileName = $info->getFilename(); 83 | }else{ 84 | // 上传失败获取错误信息 85 | return get_status(1 , $file->getError()); 86 | } 87 | } 88 | } 89 | 90 | /** 91 | * 链接检查 92 | * 93 | * @param [type] $url 94 | * @return void 95 | */ 96 | protected function checkUrl($url) 97 | { 98 | return true; 99 | } 100 | 101 | /** 102 | * 解压 103 | * 104 | * @param [type] $file 105 | * @param [type] $extension 106 | * @return void 107 | */ 108 | // public function decompression($file, $extension,$filename) 109 | // { 110 | // $zip = new \ZipArchive; 111 | // if ($zip->open($file) === TRUE) { 112 | // $zip->extractTo($this->pluginDir); 113 | // $zip->close(); 114 | // return true; 115 | // } else { 116 | // return false; 117 | // } 118 | // } 119 | // 解压 120 | public function decompression($file, $extension,$filename) 121 | { 122 | $filename = substr($filename,0, -4); 123 | //每次解压前,先将之前同名的给删除 124 | // $this->removeDir($path); 125 | $filenameTmp = $filename."_tmp"; 126 | $path = $this->pluginDir.$filename; 127 | $pathTmp = $this->pluginDir.$filenameTmp; 128 | // 已存在则更新 129 | if (file_exists($path) && is_dir($path)) removeDir($path); 130 | $zip = new \ZipArchive; 131 | if ($zip->open($file) === TRUE) { 132 | $zip->extractTo($path); 133 | $zip->close(); 134 | 135 | $dirs = scandir($path); 136 | foreach ($dirs as $key => $dir) { 137 | if($dir == $filename) { 138 | //说明里面还有一层,需要将里面的内容放到本层,然后删除该文件夹 139 | 140 | rename($path."/".$dir."/", $pathTmp); 141 | rmdir($path); 142 | rename($pathTmp, $path); 143 | } 144 | } 145 | return $path; 146 | } else { 147 | return false; 148 | } 149 | } 150 | } -------------------------------------------------------------------------------- /application/plugins/model/FileUtil.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /application/plugins/model/Plugins.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | 14 | // +---------------------------------------------------------------------- 15 | // | 应用设置 16 | // +---------------------------------------------------------------------- 17 | 18 | // 应用命名空间 19 | 'app_namespace' => 'app', 20 | // 应用调试模式 21 | 'app_debug' => true, 22 | // 应用Trace 23 | 'app_trace' => false, 24 | // 应用模式状态 25 | 'app_status' => '', 26 | // 是否支持多模块 27 | 'app_multi_module' => true, 28 | // 入口自动绑定模块 29 | 'auto_bind_module' => false, 30 | // 注册的根命名空间 31 | 'root_namespace' => [], 32 | // 扩展函数文件 33 | 'extra_file_list' => [THINK_PATH . 'helper' . EXT], 34 | // 默认输出类型 35 | 'default_return_type' => 'html', 36 | // 默认AJAX 数据返回格式,可选json xml ... 37 | 'default_ajax_return' => 'json', 38 | // 默认JSONP格式返回的处理方法 39 | 'default_jsonp_handler' => 'jsonpReturn', 40 | // 默认JSONP处理方法 41 | 'var_jsonp_handler' => 'callback', 42 | // 默认时区 43 | 'default_timezone' => 'PRC', 44 | // 是否开启多语言 45 | 'lang_switch_on' => false, 46 | // 默认全局过滤方法 用逗号分隔多个 47 | 'default_filter' => '', 48 | // 默认语言 49 | 'default_lang' => 'zh-cn', 50 | // 应用类库后缀 51 | 'class_suffix' => false, 52 | // 控制器类后缀 53 | 'controller_suffix' => false, 54 | 55 | // +---------------------------------------------------------------------- 56 | // | 模块设置 57 | // +---------------------------------------------------------------------- 58 | 59 | // 默认模块名 60 | 'default_module' => 'index', 61 | // 禁止访问模块 62 | 'deny_module_list' => ['common'], 63 | // 默认控制器名 64 | 'default_controller' => 'Index', 65 | // 默认操作名 66 | 'default_action' => 'index', 67 | // 默认验证器 68 | 'default_validate' => '', 69 | // 默认的空控制器名 70 | 'empty_controller' => 'Error', 71 | // 操作方法后缀 72 | 'action_suffix' => '', 73 | // 自动搜索控制器 74 | 'controller_auto_search' => false, 75 | 76 | // +---------------------------------------------------------------------- 77 | // | URL设置 78 | // +---------------------------------------------------------------------- 79 | 80 | // PATHINFO变量名 用于兼容模式 81 | 'var_pathinfo' => 's', 82 | // 兼容PATH_INFO获取 83 | 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'], 84 | // pathinfo分隔符 85 | 'pathinfo_depr' => '/', 86 | // URL伪静态后缀 87 | 'url_html_suffix' => 'html', 88 | // URL普通方式参数 用于自动生成 89 | 'url_common_param' => false, 90 | // URL参数方式 0 按名称成对解析 1 按顺序解析 91 | 'url_param_type' => 0, 92 | // 是否开启路由 93 | 'url_route_on' => true, 94 | // 路由使用完整匹配 95 | 'route_complete_match' => false, 96 | // 路由配置文件(支持配置多个) 97 | 'route_config_file' => ['route'], 98 | // 是否强制使用路由 99 | 'url_route_must' => false, 100 | // 域名部署 101 | 'url_domain_deploy' => false, 102 | // 域名根,如thinkphp.cn 103 | 'url_domain_root' => '', 104 | // 是否自动转换URL中的控制器和操作名 105 | 'url_convert' => true, 106 | // 默认的访问控制器层 107 | 'url_controller_layer' => 'controller', 108 | // 表单请求类型伪装变量 109 | 'var_method' => '_method', 110 | // 表单ajax伪装变量 111 | 'var_ajax' => '_ajax', 112 | // 表单pjax伪装变量 113 | 'var_pjax' => '_pjax', 114 | // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则 115 | 'request_cache' => false, 116 | // 请求缓存有效期 117 | 'request_cache_expire' => null, 118 | // 全局请求缓存排除规则 119 | 'request_cache_except' => [], 120 | 121 | // +---------------------------------------------------------------------- 122 | // | 模板设置 123 | // +---------------------------------------------------------------------- 124 | 125 | 'template' => [ 126 | // 模板引擎类型 支持 php think 支持扩展 127 | 'type' => 'Think', 128 | // 模板路径 129 | 'view_path' => '', 130 | // 模板后缀 131 | 'view_suffix' => 'html', 132 | // 模板文件名分隔符 133 | 'view_depr' => DS, 134 | // 模板引擎普通标签开始标记 135 | 'tpl_begin' => '{', 136 | // 模板引擎普通标签结束标记 137 | 'tpl_end' => '}', 138 | // 标签库标签开始标记 139 | 'taglib_begin' => '{', 140 | // 标签库标签结束标记 141 | 'taglib_end' => '}', 142 | ], 143 | 144 | // 视图输出字符串内容替换 145 | 'view_replace_str' => [], 146 | // 默认跳转页面对应的模板文件 147 | 'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', 148 | 'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', 149 | 150 | // +---------------------------------------------------------------------- 151 | // | 异常及错误设置 152 | // +---------------------------------------------------------------------- 153 | 154 | // 异常页面的模板文件 155 | 'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl', 156 | 157 | // 错误显示信息,非调试模式有效 158 | 'error_message' => '页面错误!请稍后再试~', 159 | // 显示错误信息 160 | 'show_error_msg' => false, 161 | // 异常处理handle类 留空使用 \think\exception\Handle 162 | 'exception_handle' => '', 163 | 164 | // +---------------------------------------------------------------------- 165 | // | 日志设置 166 | // +---------------------------------------------------------------------- 167 | 168 | 'log' => [ 169 | // 日志记录方式,内置 file socket 支持扩展 170 | 'type' => 'File', 171 | // 日志保存目录 172 | 'path' => LOG_PATH, 173 | // 日志记录级别 174 | 'level' => [], 175 | ], 176 | 177 | // +---------------------------------------------------------------------- 178 | // | Trace设置 开启 app_trace 后 有效 179 | // +---------------------------------------------------------------------- 180 | 'trace' => [ 181 | // 内置Html Console 支持扩展 182 | 'type' => 'Html', 183 | ], 184 | 185 | // +---------------------------------------------------------------------- 186 | // | 缓存设置 187 | // +---------------------------------------------------------------------- 188 | 189 | 'cache' => [ 190 | // 驱动方式 191 | 'type' => 'File', 192 | // 缓存保存目录 193 | 'path' => CACHE_PATH, 194 | // 缓存前缀 195 | 'prefix' => '', 196 | // 缓存有效期 0表示永久缓存 197 | 'expire' => 0, 198 | ], 199 | 200 | // +---------------------------------------------------------------------- 201 | // | 会话设置 202 | // +---------------------------------------------------------------------- 203 | 204 | 'session' => [ 205 | 'id' => '', 206 | // SESSION_ID的提交变量,解决flash上传跨域 207 | 'var_session_id' => '', 208 | // SESSION 前缀 209 | 'prefix' => 'think', 210 | // 驱动方式 支持redis memcache memcached 211 | 'type' => '', 212 | // 是否自动开启 SESSION 213 | 'auto_start' => true, 214 | ], 215 | 216 | // +---------------------------------------------------------------------- 217 | // | Cookie设置 218 | // +---------------------------------------------------------------------- 219 | 'cookie' => [ 220 | // cookie 名称前缀 221 | 'prefix' => '', 222 | // cookie 保存时间 223 | 'expire' => 0, 224 | // cookie 保存路径 225 | 'path' => '/', 226 | // cookie 有效域名 227 | 'domain' => '', 228 | // cookie 启用安全传输 229 | 'secure' => false, 230 | // httponly设置 231 | 'httponly' => '', 232 | // 是否使用 setcookie 233 | 'setcookie' => true, 234 | ], 235 | 236 | //分页配置 237 | 'paginate' => [ 238 | 'type' => 'bootstrap', 239 | 'var_page' => 'page', 240 | 'list_rows' => 15, 241 | ], 242 | 243 | 'http_exception_template' => [ 244 | // 定义404错误的重定向页面地址 245 | 404 => APP_PATH.'404.html', 246 | ], 247 | 'captcha' => [ 248 | // 字体大小 249 | 'fontSize' => 22, 250 | // 验证码长度(位数) 251 | 'length' => 4, 252 | ] 253 | ]; 254 | -------------------------------------------------------------------------------- /application/release/controller/Index.php: -------------------------------------------------------------------------------- 1 | field('pid,viewsnum,ispuh,sname,is_pwd,img,token,expiredate,link,createtime,ptype') 19 | ->paginate($this->rollPage); 20 | 21 | $count = count($result); 22 | 23 | return $this->fetch('index' , ['static' => $static,'result' => $result,'count' => $count]); 24 | } 25 | 26 | /** 27 | * 验证发布密码 28 | */ 29 | public function valiView() 30 | { 31 | //接收数据 32 | $input = input('get.'); 33 | 34 | //判断数据是否接收成功 35 | if(!$input) { 36 | return jsonRetuen(1,'数据接收失败' , 2000); 37 | } 38 | $keys = ["pid"]; 39 | //验证传值 40 | $vali = valiKeys($keys , $input); 41 | //判断传值是否满足 42 | if($vali['err'] != 0) { 43 | return jsonRetuen(1,$vali['data'] , 2000); 44 | } 45 | //查询相关发布 46 | $result = Db::name('publish')->where('scid',$input['pid'])->find(); 47 | //判断查询是否为空 48 | if(empty($result)){ 49 | return jsonRetuen(1,'未找到发布信息' ,6005); 50 | } 51 | //判断是否需要验证token 52 | if(!empty($result['token'])){ 53 | //判断是否有token传入 54 | if(isset($input['token'])) { 55 | //验证token 56 | if($result['token'] != $input['token']) { 57 | return jsonRetuen(1,'发布token验证失败' , 6006); 58 | } 59 | }else { 60 | return jsonRetuen(1,'非法进入页面' , 6007); 61 | } 62 | } 63 | //验证是否已过期 64 | if($result['expiredate'] < time() && $result['expiredate'] != 0) { 65 | return jsonRetuen(1,'发布链接已过期',6008); 66 | } 67 | 68 | //判断是否开启密码 69 | if($result['is_pwd'] == 0) { 70 | return jsonRetuen(0,'未开启密码保护'); 71 | } 72 | 73 | //验证password是否传入 74 | $keys = ["password"]; 75 | //验证传值 76 | $vali = valiKeys($keys , $input); 77 | 78 | //判断是否有password传入 79 | if(!isset($input['password'])) { 80 | return jsonRetuen(1,'发布链接访问密码错误' , 6009); 81 | } 82 | 83 | //判断密码是否一致 84 | if(decrypt($input['password'],$input['len']) == $result['password']) { 85 | return jsonRetuen(0,'密码验证成功'); 86 | }else{ 87 | return jsonRetuen(1,'发布链接访问密码错误' , 6009); 88 | } 89 | } 90 | 91 | /** 92 | * 获取发布名字及是否有密码 93 | */ 94 | public function publishMsg() 95 | { 96 | //接收数据 97 | $input = input('get.'); 98 | 99 | //判断数据是否接收成功 100 | if(!$input) { 101 | return jsonRetuen(1,'数据接收失败' , 2000); 102 | } 103 | //查询相关发布 104 | $result = Db::name('publish')->where('scid',$input['pid'])->find(); 105 | 106 | //判断是否开启密码 107 | if($result) { 108 | //将发布浏览次数+1 109 | Db::name('publish')->where('scid',$input['pid'])->update(['viewsnum' => $result['viewsnum']+1]); 110 | return jsonRetuen(0,['name'=>$result['sname'] , 'is_pwd' => $result['is_pwd']]); 111 | }else { 112 | return jsonRetuen(1,'发布信息错误',6010); 113 | } 114 | } 115 | 116 | } -------------------------------------------------------------------------------- /application/route.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return []; 13 | 14 | // return [ 15 | // '__pattern__' => [ 16 | // 'name' => '\w+', 17 | // ], 18 | // '[hello]' => [ 19 | // ':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']], 20 | // ':name' => ['index/hello', ['method' => 'post']], 21 | // ], 22 | 23 | // ]; 24 | -------------------------------------------------------------------------------- /application/tags.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // 应用行为扩展定义文件 13 | 14 | return [ 15 | // 应用初始化 16 | 'app_init' => [], 17 | // 应用开始 18 | 'app_begin' => [], 19 | // 模块初始化 20 | 'module_init' => [], 21 | // 操作开始执行 22 | 'action_begin' => [], 23 | // 视图内容过滤 24 | 'view_filter' => [], 25 | // 日志写入 26 | 'log_write' => [], 27 | // 应用结束 28 | 'app_end' => [], 29 | ]; 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /application/user/model/User.php: -------------------------------------------------------------------------------- 1 | where($where)->find(); 21 | if($result){ 22 | return $result; 23 | }else{ 24 | return false; 25 | } 26 | } 27 | 28 | //获取用户组 29 | public function getRole($uid) 30 | { 31 | $result = Db::name('user_role')->where(['uid' => $uid])->find(); 32 | if($result){ 33 | return $result; 34 | }else{ 35 | return false; 36 | } 37 | } 38 | 39 | //获取权限名字 40 | public function getPid($rid) 41 | { 42 | $result = Db::name('role_permission')->where(['rid' => $rid])->find(); 43 | if($result){ 44 | return $result; 45 | }else{ 46 | return false; 47 | } 48 | } 49 | 50 | //获取用户组名 51 | public function getRolename($rid) 52 | { 53 | $result = Db::name('role')->where(['rid' =>$rid])->find(); 54 | if($result){ 55 | return $result; 56 | }else{ 57 | return false; 58 | } 59 | } 60 | 61 | //获取权限 62 | public function getPermission($pid) 63 | { 64 | $result = Db::name('permission')->select($pid); 65 | if($result){ 66 | return $result; 67 | }else{ 68 | return false; 69 | } 70 | } 71 | 72 | //插入 $table 表名 $data 数据 73 | public function messgeAdd( $table , $data) 74 | { 75 | $result = Db::name($table)->insert($data); 76 | if($result) { 77 | return $result; 78 | }else { 79 | return false; 80 | } 81 | } 82 | 83 | 84 | //修改 $table 表名 $where 条件 $data 数据 85 | public function messgeUptate( $table , $where , $data ) 86 | { 87 | 88 | $result = Db::name($table)->where($where)->update($data); 89 | if($result) { 90 | return $result; 91 | }else { 92 | return false; 93 | } 94 | } 95 | 96 | //删除 $table 表名 $where 条件 97 | public function messgeDlete($table , $where) 98 | { 99 | $result = Db::name($table)->where($where)->delete(); 100 | if($result) { 101 | return $result; 102 | }else { 103 | return false; 104 | } 105 | } 106 | 107 | //获取信息 $table 表名 $where 条件 $column 字段 108 | public function getMessge($table , $where = null ) 109 | { 110 | $result = Db::name($table)->where($where)->select(); 111 | if($result) { 112 | return $result; 113 | }else { 114 | return false; 115 | } 116 | } 117 | 118 | //删除信息 $table 表名 , $where 条件 数组or字符串 119 | public function deleteMessg($table,$where) 120 | { 121 | $result = Db::name($table)->where($where)->delete(); 122 | if($result) { 123 | return $result; 124 | }else { 125 | return false; 126 | } 127 | } 128 | 129 | 130 | //增加用户 return 自增ID 131 | public function messageAdd($table,$data) 132 | { 133 | $result = Db::name($table)->insert($data); 134 | $userId = Db::name($table)->getLastInsID(); 135 | if($result && $userId) { 136 | return $userId; 137 | }else { 138 | return false; 139 | } 140 | } 141 | 142 | 143 | } 144 | 145 | -------------------------------------------------------------------------------- /application/websocket/controller/Setting.php: -------------------------------------------------------------------------------- 1 | where('type', 'socket')->find(); 16 | $config = json_decode($result['config'], true); 17 | $data['url'] = $arr['setting']['realData']['url']; 18 | $data['status'] = $config['status'] ?? 0; 19 | $data['php_path'] = $config['php_path'] ?? ''; 20 | if (empty($file)) { 21 | return get_status(1, null); 22 | } else { 23 | return get_status(0, $data); 24 | } 25 | } 26 | 27 | public function set() 28 | { 29 | //获取数据 30 | $put = file_get_contents('php://input'); 31 | if (empty($put)) { 32 | return get_status(1, null); 33 | } 34 | $post = json_decode($put, 1); 35 | $path = config('static_config_path'); 36 | $file = file_get_contents($path); 37 | //转成数组 38 | $arr = json_decode($file, 1); 39 | $arr['setting']['realData']['url'] = $post['url']; 40 | $arr['setting']['server'] = $_SERVER['REQUEST_SCHEME']. '://' .$_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']; 41 | $jsondata = json_encode($arr, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT); 42 | $data = file_put_contents($path, $jsondata, FILE_USE_INCLUDE_PATH); 43 | $result = Db::name('systemset')->where('type', 'socket')->find(); 44 | $config = json_decode($result['config'], true); 45 | $inputConfig = ['status' => $post['status'], 'php_path' => $post['php_path']]; 46 | if (!$result) { 47 | Db::name('systemset')->where('type', 'socket')->insert(['type' => 'socket', 'config' => json_encode($inputConfig)]); 48 | } else { 49 | Db::name('systemset')->where('type', 'socket')->update(['config' => json_encode($inputConfig)]); 50 | } 51 | $status = $config['status'] ?? 0; 52 | $msg = '修改成功'; 53 | if ($status != $post['status']) { 54 | $returnData = $this->runSocket($post['status'], $post['php_path']); 55 | return get_status($returnData[0], $returnData[1]); 56 | } 57 | if (empty($data)) { 58 | return get_status(1, $msg); 59 | } else { 60 | return get_status(0, $msg); 61 | } 62 | } 63 | 64 | public function runSocket($status, $phpPath) 65 | { 66 | if (!$status) { 67 | return $this->stopSocket($phpPath); 68 | } 69 | if (!$phpPath) { 70 | $phpPath = 'php'; 71 | } 72 | try { 73 | $commandStr = 'cd ' . ROOT_PATH . ' & nohup ' . $phpPath . ' ' . ROOT_PATH . 'Socket_server.php >' . ROOT_PATH . 'socket.log 2>&1& echo $! >' . ROOT_PATH . 'socket.pid'; 74 | exec($commandStr); 75 | return [0, '开启socket成功']; 76 | } catch (\Exception $e) { 77 | return [1, '启动失败,请检查php路径并放开exce函数(此功能不支持winserver)']; 78 | } 79 | } 80 | 81 | public function stopSocket() 82 | { 83 | if (!file_exists(ROOT_PATH . 'socket.pid')) { 84 | return [0, '修改成功']; 85 | } 86 | try { 87 | $commandStr = 'kill `cat ' . ROOT_PATH . 'socket.pid`'; 88 | exec($commandStr); 89 | @unlink(ROOT_PATH . 'socket.pid'); 90 | return [0, '关闭socket成功']; 91 | } catch (\Exception $e) { 92 | return [1, '关闭socket失败']; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /build.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | // 生成应用公共文件 14 | '__file__' => ['common.php', 'config.php', 'database.php'], 15 | 16 | // 定义demo模块的自动生成 (按照实际定义的文件名生成) 17 | 'demo' => [ 18 | '__file__' => ['common.php'], 19 | '__dir__' => ['behavior', 'controller', 'model', 'view'], 20 | 'controller' => ['Index', 'Test', 'UserType'], 21 | 'model' => ['User', 'UserType'], 22 | 'view' => ['index/index'], 23 | ], 24 | // 其他更多的模块定义 25 | ]; 26 | -------------------------------------------------------------------------------- /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 | "tp5er/tp5-databackup": "^1.0", 22 | "topthink/think-image": "^1.0", 23 | "phpoffice/phpspreadsheet": "v1.5.2" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "app\\": "application" 28 | } 29 | }, 30 | "extra": { 31 | "think-path": "thinkphp" 32 | }, 33 | "config": { 34 | "preferred-install": "dist" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /doc/FAQ.md: -------------------------------------------------------------------------------- 1 | ## 常见问题 2 | 3 | - **安装部署后无法登录,提示500错误** 4 | 5 | 答:取消禁用php函数 putenv(在php.ini的disable_function中将 putenv删除) 6 | 7 | - **安装部署后无法登录,提示404错误** 8 | 9 | 答:web服务器新增伪静态 10 | 11 | ```bash 12 | ## nginx 13 | location / { 14 | if (!-e $request_filename) { 15 | rewrite ^(.*)$ /index.php?s=/$1 last; 16 | break; 17 | } 18 | } 19 | ``` 20 | 21 | ```bash 22 | ## apache 23 | 24 | Options +FollowSymlinks -Multiviews 25 | RewriteEngine on 26 | RewriteCond %{REQUEST_FILENAME} !-d 27 | RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] 28 | 29 | ``` 30 | 31 | 32 | 33 | - **若遇到乱码问题** 34 | 35 | 答:1.检查数据库字符集是否异常 36 | 37 | ​ 2.检查数据库版本(建议采用mysql5.6、mysql5.7) 38 | 39 | 3.暂时不建议使用maridb 40 | 41 | - **样式异常问题** 42 | 43 | 答:推荐以下浏览器 44 | 45 | 1. chrome(谷歌浏览器) 46 | 2. firefox(火狐浏览器) 47 | 3. edge(新版edge) 48 | 49 | - 其他问题 50 | 51 | 提交issue 52 | 53 | 或者加qq群:**328601229** -------------------------------------------------------------------------------- /doc/plugin.md: -------------------------------------------------------------------------------- 1 | ## 云组件中心模块说明 2 | 3 | ### 开发规范 4 | 5 | #### HTML 6 | 7 | - 中划线命名 eg: class="user-list" 8 | - 语义化 易读性 eg: user, list 不要aa,bb,cc类似的 9 | - 少用浮动和定位 : 使用的flex 10 | - 行内元素禁止嵌套块级元素,特殊情况除外 11 | - 表格形式的布局尽量用 table 12 | - 列表形式的布局尽量用 ul,li 13 | - 重复的HTMl,写成组件,增加复用性 14 | - 尽量每一个模块都要有注释 15 | - 尽量 不用id 16 | - 能用字体的不要使用图片 17 | 18 | ### css 19 | 20 | - css选择器最好不要嵌套超过4层 21 | - 多用css3的属性 22 | - 每一个模块尽量注释 23 | - 命名语义化和中划线形式 24 | - 预编译器采用less 25 | - 重复性的样式写成函数 26 | - 组件内部的样式比较多的,写成外部样式,引入 27 | 28 | ### JavaScript 29 | 30 | - js语法统一使用es6的语法 31 | - 变量命名用小驼峰命名 eg:userList 32 | - 组件统一采用大驼峰命名 eg: UserList 33 | - 变量声明用let 34 | - 所用的常量都要用const定义在使用 35 | - 函数使用箭头函数 36 | 37 | ## 插件开发指导 38 | 39 | - 配置:命名为: plugin.xml 40 | 41 | ``` 42 | 43 | 44 | test_clound_compontent 45 | 1.0 46 | 作者名称 47 | 2020-07-19 48 | 测试组件 49 | preview.png 50 | index.html 51 | index.js 52 | testData.json 53 | TestBar 54 | 55 | 56 | 57 | public/echarts.js 58 | public/jquery.min.js 59 | 60 | 61 | public/index.css 62 | 63 | 64 | 65 | true 66 | 1 67 | false 68 | 请选择数据的字段 69 | category 70 | 71 | 72 | true 73 | n 74 | false 75 | 请选择数据的字段 76 | value 77 | 78 | 79 | 80 | 81 | xEn 82 | x轴单位 83 | textbox 84 | 85 | x轴单位 86 | 87 | 88 | yEn 89 | y轴单位 90 | textbox 91 | 92 | y轴单位 93 | 94 | 95 | 96 | ``` 97 | 98 | - html: 命名为index.html 99 | 100 | 示例: 101 | 102 | ```html 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 119 | 120 | 121 |
122 | 123 | 200 | ``` 201 | 202 | - JavaScript: 根据plugin.xml进行配置 203 | 204 | - CSS:根据plugin.xml进行配置 205 | 206 | - 静态数据: 207 | 208 | - 预览图:根据plugin.xml进行配置 209 | 210 | - 公共资源库: 211 | 212 | 1. 发行包中public目录下CommonPlugins目录为公共插件资源 213 | 214 | 2. 已存在的有echarts、jquery 215 | 216 | 3. 用法示例 217 | 218 | ```html 219 | 220 | 221 | 222 | 223 | ``` 224 | 225 | 可用的公共资源如下: 226 | 227 | echarts4.8 228 | 229 | ```html 230 | 231 | ``` 232 | 233 | echarts5.0 234 | 235 | ```html 236 | 237 | ``` 238 | 239 | jquery3.5 240 | 241 | ```html 242 | 243 | ``` 244 | 245 | **请注意在使用公共资源时一定要保持plugin.xml与index.html保持一致** 246 | 247 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | openbi: 5 | restart: always 6 | depends_on: 7 | - mysql 8 | - redis 9 | build: ./docker 10 | volumes: 11 | - ./:/data 12 | ports: 13 | - 80:80 14 | ulimits: 15 | nofile: 16 | soft: 262144 17 | hard: 262144 18 | 19 | mysql: 20 | image: mysql:8 21 | restart: always 22 | environment: 23 | MYSQL_ROOT_PASSWORD: root 24 | volumes: 25 | - ./data/mysql:/var/lib/mysql 26 | command: --max_connections=512 --explicit_defaults_for_timestamp=1 --default_authentication_plugin=mysql_native_password 27 | --tmp_table_size=18M --thread_cache_size=8 --myisam_max_sort_file_size=1G --server-id=1 --log-bin=/var/lib/mysql/mysql-bin.log --gtid-mode=ON --enforce-gtid-consistency 28 | --myisam_sort_buffer_size=35M --key_buffer_size=25M --read_buffer_size=64K --read_rnd_buffer_size=256K --sort_buffer_size=256K 29 | --max_allowed_packet=128M --innodb_flush_log_at_trx_commit=1 --innodb_log_buffer_size=1M --sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' 30 | --innodb_buffer_pool_size=47M --innodb_log_file_size=24M --innodb_thread_concurrency=8 --default-time-zone="+8:00" 31 | ports: 32 | - 3306:3306 33 | 34 | redis: 35 | image: redis:alpine 36 | restart: always 37 | volumes: 38 | - ./data:/data 39 | ports: 40 | - 6379:6379 41 | 42 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3-fpm-alpine 2 | 3 | ENV TIMEZONE Asia/Shanghai 4 | 5 | COPY --from=composer /usr/bin/composer /usr/bin/composer 6 | 7 | RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories 8 | ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php 9 | 10 | #基础依赖 11 | RUN apk update \ 12 | && apk add --no-cache --virtual .build-deps \ 13 | autoconf \ 14 | build-base \ 15 | binutils \ 16 | musl \ 17 | linux-headers &&\ 18 | apk add tzdata runit nginx freetype-dev gd-dev libjpeg-turbo-dev libpng-dev libmcrypt-dev libevent-dev bash libzip-dev gnu-libiconv openldap-dev && \ 19 | cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \ 20 | echo "${TIMEZONE}" > /etc/timezone && \ 21 | sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /usr/local/etc/php-fpm.conf && \ 22 | sed -i -e "s/listen\s*=\s*127.0.0.1:9000/listen = 9000/g" /usr/local/etc/php-fpm.d/www.conf && \ 23 | docker-php-ext-configure gd --with-freetype-dir --with-jpeg-dir &&\ 24 | docker-php-ext-install -j$(nproc) gd &&\ 25 | docker-php-ext-install pdo_mysql mysqli bcmath sockets opcache zip ldap && pecl channel-update pecl.php.net && pecl install seaslog redis xdebug &&\ 26 | docker-php-ext-enable redis opcache && pecl clear-cache &&\ 27 | echo -e "opcache.enable=1\nopcache.enable_cli=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini &&\ 28 | mkdir -p /run/nginx \ 29 | && apk del .build-deps \ 30 | && rm -rf /var/cache/apk/* /tmp/* /usr/share/man \ 31 | && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 32 | 33 | ADD ./php.ini /usr/local/etc/php/php.ini 34 | ADD ./nginx.service /etc/service/nginx/run 35 | RUN chmod a+x /etc/service/nginx/run 36 | ADD ./fpm.service /etc/service/fpm/run 37 | RUN chmod a+x /etc/service/fpm/run 38 | ADD ./nginx.conf /etc/nginx/nginx.conf 39 | ADD ./default.conf /etc/nginx/conf.d/default.conf 40 | RUN chmod a+x /usr/bin/composer 41 | 42 | WORKDIR /data 43 | 44 | EXPOSE 80 45 | CMD ["runsvdir", "/etc/service"] -------------------------------------------------------------------------------- /docker/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; 4 | access_log off; 5 | root /data/public; 6 | index index.html index.htm index.php; 7 | location ~ [^/]\.php(/|$) { 8 | fastcgi_pass 127.0.0.1:9000; 9 | fastcgi_index index.php; 10 | include fastcgi.conf; 11 | } 12 | location / { 13 | if (!-e $request_filename) { 14 | rewrite ^(.*)$ /index.php?s=$1 last; 15 | break; 16 | } 17 | } 18 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { 19 | expires 30d; 20 | access_log off; 21 | } 22 | location ~ .*\.(js|css|ttf|woff|woff2)?$ { 23 | expires 7d; 24 | access_log off; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docker/fpm.service: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec php-fpm 3 | 4 | -------------------------------------------------------------------------------- /docker/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | 3 | # Set number of worker processes automatically based on number of CPU cores. 4 | worker_processes auto; 5 | 6 | # Enables the use of JIT for regular expressions to speed-up their processing. 7 | pcre_jit on; 8 | 9 | # Configures default error logger. 10 | error_log /var/log/nginx/error.log warn; 11 | 12 | # Includes files with directives to load dynamic modules. 13 | include /etc/nginx/modules/*.conf; 14 | 15 | worker_rlimit_nofile 65535; 16 | events { 17 | use epoll; 18 | worker_connections 65535; 19 | } 20 | 21 | http { 22 | include /etc/nginx/mime.types; 23 | default_type application/octet-stream; 24 | 25 | server_tokens off; 26 | server_names_hash_bucket_size 128; 27 | client_header_buffer_size 4k; 28 | large_client_header_buffers 4 32k; 29 | client_max_body_size 80m; 30 | 31 | sendfile on; 32 | tcp_nopush on; 33 | 34 | client_body_timeout 5; 35 | client_header_timeout 5; 36 | keepalive_timeout 5; 37 | send_timeout 5; 38 | 39 | open_file_cache max=65535 inactive=20s; 40 | open_file_cache_valid 30s; 41 | open_file_cache_min_uses 1; 42 | 43 | tcp_nodelay on; 44 | 45 | fastcgi_connect_timeout 300; 46 | fastcgi_send_timeout 300; 47 | fastcgi_read_timeout 300; 48 | fastcgi_buffer_size 64k; 49 | fastcgi_buffers 4 64k; 50 | fastcgi_busy_buffers_size 128k; 51 | fastcgi_temp_file_write_size 128k; 52 | 53 | client_body_buffer_size 512k; 54 | proxy_connect_timeout 5; 55 | proxy_read_timeout 60; 56 | proxy_send_timeout 5; 57 | proxy_buffer_size 16k; 58 | proxy_buffers 4 64k; 59 | proxy_busy_buffers_size 128k; 60 | proxy_temp_file_write_size 128k; 61 | 62 | gzip on; 63 | gzip_min_length 1k; 64 | gzip_buffers 4 16k; 65 | gzip_http_version 1.0; 66 | gzip_comp_level 2; 67 | gzip_types text/plain application/x-javascript text/css application/xml; 68 | gzip_vary on; 69 | 70 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 71 | '$status $body_bytes_sent "$http_referer" ' 72 | '"$http_user_agent" "$http_x_forwarded_for"'; 73 | 74 | #websocket 需要加下这个 75 | map $http_upgrade $connection_upgrade { 76 | default upgrade; 77 | '' close; 78 | } 79 | 80 | # Sets the path, format, and configuration for a buffered log write. 81 | access_log /var/log/nginx/access.log main; 82 | 83 | 84 | # Includes virtual hosts configs. 85 | include /etc/nginx/conf.d/*.conf; 86 | } -------------------------------------------------------------------------------- /docker/nginx.service: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p /run/nginx && nginx -c /etc/nginx/nginx.conf -t && \ 3 | nginx -c /etc/nginx/nginx.conf -g "daemon off;" 4 | 5 | -------------------------------------------------------------------------------- /docker/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | engine = On 3 | 4 | short_open_tag = Off 5 | 6 | precision = 14 7 | 8 | output_buffering = 4096 9 | 10 | zlib.output_compression = Off 11 | 12 | implicit_flush = Off 13 | 14 | unserialize_callback_func = 15 | 16 | serialize_precision = 17 17 | 18 | disable_functions = 19 | 20 | disable_classes = 21 | 22 | zend.enable_gc = On 23 | 24 | expose_php = On 25 | 26 | max_execution_time = 0 27 | 28 | max_input_time = 60 29 | 30 | memory_limit = 2048M 31 | 32 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 33 | 34 | display_errors = Off 35 | 36 | display_startup_errors = Off 37 | 38 | log_errors = On 39 | 40 | log_errors_max_len = 1024 41 | 42 | ignore_repeated_errors = Off 43 | 44 | ignore_repeated_source = Off 45 | 46 | report_memleaks = On 47 | 48 | track_errors = Off 49 | 50 | html_errors = On 51 | 52 | variables_order = "GPCS" 53 | 54 | request_order = "GP" 55 | 56 | register_argc_argv = Off 57 | 58 | auto_globals_jit = On 59 | 60 | post_max_size = 128M 61 | 62 | auto_prepend_file = 63 | 64 | auto_append_file = 65 | 66 | default_mimetype = "text/html" 67 | 68 | default_charset = "UTF-8" 69 | 70 | doc_root = 71 | 72 | user_dir = 73 | 74 | enable_dl = Off 75 | 76 | file_uploads = On 77 | 78 | upload_max_filesize = 128M 79 | 80 | max_file_uploads = 100 81 | 82 | allow_url_fopen = On 83 | 84 | allow_url_include = Off 85 | 86 | default_socket_timeout = 60 87 | 88 | [CLI Server] 89 | cli_server.color = On 90 | 91 | [Date] 92 | date.timezone = "Asia/Shanghai" 93 | [filter] 94 | 95 | [iconv] 96 | 97 | [intl] 98 | 99 | [sqlite3] 100 | 101 | [Pcre] 102 | 103 | [Pdo] 104 | 105 | [Pdo_mysql] 106 | pdo_mysql.cache_size = 2000 107 | 108 | pdo_mysql.default_socket = 109 | 110 | [Phar] 111 | 112 | [mail function] 113 | 114 | SMTP = localhost 115 | 116 | smtp_port = 25 117 | 118 | mail.add_x_header = Off 119 | 120 | [SQL] 121 | sql.safe_mode = Off 122 | 123 | [ODBC] 124 | odbc.allow_persistent = On 125 | 126 | odbc.check_persistent = On 127 | 128 | odbc.max_persistent = -1 129 | 130 | odbc.max_links = -1 131 | 132 | odbc.defaultlrl = 4096 133 | 134 | odbc.defaultbinmode = 1 135 | 136 | [Interbase] 137 | ibase.allow_persistent = 1 138 | 139 | ibase.max_persistent = -1 140 | 141 | ibase.max_links = -1 142 | 143 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 144 | 145 | ibase.dateformat = "%Y-%m-%d" 146 | 147 | ibase.timeformat = "%H:%M:%S" 148 | 149 | [MySQLi] 150 | 151 | mysqli.max_persistent = -1 152 | 153 | mysqli.allow_persistent = On 154 | 155 | mysqli.max_links = -1 156 | 157 | mysqli.cache_size = 2000 158 | 159 | mysqli.default_port = 3306 160 | 161 | mysqli.default_socket = 162 | 163 | mysqli.default_host = 164 | 165 | mysqli.default_user = 166 | 167 | mysqli.default_pw = 168 | 169 | mysqli.reconnect = Off 170 | 171 | [mysqlnd] 172 | mysqlnd.collect_statistics = On 173 | 174 | mysqlnd.collect_memory_statistics = Off 175 | 176 | [OCI8] 177 | 178 | [PostgreSQL] 179 | pgsql.allow_persistent = On 180 | 181 | pgsql.auto_reset_persistent = Off 182 | 183 | pgsql.max_persistent = -1 184 | 185 | pgsql.max_links = -1 186 | 187 | pgsql.ignore_notice = 0 188 | 189 | pgsql.log_notice = 0 190 | 191 | [bcmath] 192 | bcmath.scale = 0 193 | 194 | [browscap] 195 | 196 | [Session] 197 | session.save_handler = files 198 | 199 | session.use_strict_mode = 0 200 | 201 | session.use_cookies = 1 202 | 203 | session.use_only_cookies = 1 204 | 205 | session.name = PHPSESSID 206 | 207 | session.auto_start = 0 208 | 209 | session.cookie_lifetime = 0 210 | 211 | session.cookie_path = / 212 | 213 | session.cookie_domain = 214 | 215 | session.cookie_httponly = 216 | 217 | session.serialize_handler = php 218 | 219 | session.gc_probability = 1 220 | 221 | session.gc_divisor = 1000 222 | 223 | session.gc_maxlifetime = 7200 224 | 225 | session.referer_check = 226 | 227 | session.cache_limiter = nocache 228 | 229 | session.cache_expire = 180 230 | 231 | session.use_trans_sid = 0 232 | 233 | session.sid_length = 26 234 | 235 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 236 | 237 | session.sid_bits_per_character = 5 238 | [Assertion] 239 | zend.assertions = -1 240 | 241 | [COM] 242 | 243 | [mbstring] 244 | 245 | [gd] 246 | 247 | [exif] 248 | 249 | [Tidy] 250 | 251 | tidy.clean_output = Off 252 | 253 | [soap] 254 | soap.wsdl_cache_enabled = 1 255 | 256 | soap.wsdl_cache_dir = "/tmp" 257 | 258 | soap.wsdl_cache_ttl = 86400 259 | 260 | soap.wsdl_cache_limit = 5 261 | 262 | [sysvshm] 263 | 264 | [ldap] 265 | ldap.max_links = -1 266 | 267 | [mcrypt] 268 | 269 | [dba] 270 | 271 | [opcache] 272 | ; opcache.enable=1 273 | ; opcache.enable_cli=1 274 | ; opcache.jit=1205 275 | ; opcache.jit_buffer_size=64M 276 | [curl] 277 | 278 | [openssl] -------------------------------------------------------------------------------- /extend/DataSource.php: -------------------------------------------------------------------------------- 1 | 'Currency', 8 | 'sqlsrv' => 'Currency', 9 | 'pgsql' => 'Currency', 10 | 'oracle' => 'Oracle', 11 | 'mongo' => 'Mongo', 12 | 'es' => 'Elasticsearch' 13 | ]; 14 | 15 | protected static $link = []; 16 | 17 | 18 | public static function connect($config = []) 19 | { 20 | $className = self::$types[$config['type']]; 21 | $class = '\\datasource\\'.$className; 22 | return $class::getInstance($config); 23 | } 24 | 25 | 26 | // // 测试连接 27 | abstract function testConnection(); 28 | 29 | // 数据实例 30 | abstract public function query($sql); 31 | 32 | // 获取字段 33 | abstract public function getFields($tableName); 34 | 35 | // 获取表 36 | abstract public function getTables(); 37 | 38 | // // 获取表所有数据 39 | abstract public function selectTables($tableName); 40 | 41 | // 性能语句分析 42 | abstract protected function getExplain($sql); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /extend/datasource/Currency.php: -------------------------------------------------------------------------------- 1 | 'show databases', 20 | 'pgsql' => "SELECT datname FROM pg_database", 21 | 'sqlite' => 'show status', 22 | 'sqlsrv' => "SELECT NAME FROM MASTER.DBO.SYSDATABASES ORDER BY NAME", 23 | ]; 24 | protected $tableSqls = [ 25 | 'mysql' => "show tables", 26 | 'pgsql' => "SELECT tablename FROM pg_tables WHERE schemaname='public'", 27 | 'sqlite' => "SELECT name as tablename from sqlite_master where type='table' order by name", 28 | 'sqlsrv' => "SELECT Name as tablename FROM SysObjects WHERE XType='U' ORDER BY Name", 29 | ]; 30 | 31 | protected function __construct($config) 32 | { 33 | if ($config['type'] == 'pgsql') $config['database'] = 'postgres'; 34 | $this->config = $config; 35 | $this->conn = Db::connect($config); 36 | } 37 | 38 | public static function getInstance($config) 39 | { 40 | if (null === self::$instance) { 41 | self::$instance = new self($config); 42 | } 43 | return self::$instance; 44 | } 45 | 46 | // 发送sql语句 47 | public function query($sql) 48 | { 49 | try { 50 | return $this->conn->query($sql); 51 | } catch (\Exception $e) { 52 | return false; 53 | } 54 | } 55 | 56 | // // 测试连接 57 | public function testConnection() 58 | { 59 | $type = $this->config['type'] ?? 'mysql'; 60 | $sql = $this->testSqls[$type]; 61 | $result = $this->query($sql); 62 | if (!$result) return false; 63 | $databases = []; 64 | foreach ($result as &$value) { 65 | $value = array_values($value); 66 | $databases[] = $value[0]; 67 | } 68 | return $databases; 69 | } 70 | 71 | 72 | // 获取字段 73 | public function getFields($tableName){} 74 | 75 | // 获取表 76 | public function getTables() 77 | { 78 | $type = $this->config['type'] ?? 'mysql'; 79 | $sql = $this->tableSqls[$type]; 80 | // return $this->query($sql); 81 | $result = $this->query($sql); 82 | if (!$result) return false; 83 | // dump($result);die; 84 | foreach ($result as &$value) { 85 | $value = array_values($value)[0]; 86 | } 87 | return $result; 88 | } 89 | 90 | // // 获取表所有数据 91 | public function selectTables($tableName) 92 | { 93 | return $this->query("select * from " . $tableName); 94 | } 95 | 96 | // 性能语句分析 97 | public function getExplain($sql){} 98 | 99 | } 100 | -------------------------------------------------------------------------------- /extend/datasource/Elasticsearch.php: -------------------------------------------------------------------------------- 1 | config = $config; 21 | $username = $config['username']? $config['username'] .':' : ""; 22 | $password = $config['password']? $config['password'] .'@' : ""; 23 | $this->params = array( 24 | 'http://'.$username.$password.$config['hostname'].':'.$config['hostport'] 25 | ); 26 | $this->conn = ClientBuilder::create()->setHosts($this->params)->build(); 27 | } 28 | 29 | public static function getInstance($config) 30 | { 31 | if (null === self::$instance) { 32 | self::$instance = new self($config); 33 | } 34 | return self::$instance; 35 | } 36 | 37 | // 发送sql语句 38 | public function query($sql) 39 | { 40 | try { 41 | $result = $this->conn->search($sql); 42 | $hits = $result['hits'] ?? []; 43 | $aggregations = $result['aggregations'] ?? []; 44 | if ($aggregations) { 45 | $buckets = array_column($aggregations, 'buckets'); 46 | $aggregation = array_shift($buckets); 47 | return $aggregation; 48 | } 49 | return array_column($hits['hits'], '_source'); 50 | } catch (\Exception $e) { 51 | return false; 52 | } 53 | } 54 | 55 | // // 测试连接 56 | public function testConnection() 57 | { 58 | //获取ES索引列表 (不需要判断异常) 59 | $result = file_get_contents($this->params[0].'/_cat/indices?v'); 60 | //判断获取到的字符串是否有双空格 61 | $vali = strpos( $result, ' '); 62 | while ($vali) { 63 | //将双空格改为单空格 64 | $result = str_replace(' ' , ' ' , $result); 65 | $vali = strpos( $result, ' '); 66 | } 67 | //以空格分割成字符串 68 | $arr = explode(' ' , $result); 69 | //找规律获取es索引 第一个为11 以后为11+9+9+9 70 | $i = 11; 71 | //定义索引存储数组 72 | $indexList = []; 73 | //判断是否存在该键 74 | while(isset($arr[$i])) { 75 | //判断$arr[$i]是否已.开头 76 | if($arr[$i][0] != '.') { 77 | $indexList[] = $arr[$i]; 78 | } 79 | $i += 9; 80 | } 81 | //返回索引数组 不许判断是否为空 82 | return $indexList; 83 | } 84 | 85 | 86 | // 获取字段 87 | public function getFields($tableName){} 88 | 89 | // 获取表 90 | public function getTables() 91 | { 92 | //查询语句 93 | $params = [ 94 | 'index' => $this->config['database'], 95 | 'body' => [ 96 | 'size' => 0, 97 | '_source'=>['_type'], 98 | 'aggs' => [ 99 | 'all_interests' =>[ 100 | 'terms' => [ 101 | 'field' => '_type' 102 | ] 103 | ] 104 | ] 105 | 106 | ] 107 | ]; 108 | //执行查询 109 | $data = $this->conn->search($params); 110 | //给聚合赋值 111 | $buckets = $data['aggregations']['all_interests']['buckets'] ?? false; 112 | if (!$buckets) return false; 113 | return array_column($buckets, 'key'); 114 | } 115 | 116 | // 获取表所有数据 117 | public function selectTables($tableName) 118 | { 119 | return []; 120 | } 121 | 122 | // 性能语句分析 123 | public function getExplain($sql){} 124 | 125 | } 126 | -------------------------------------------------------------------------------- /extend/datasource/Mongo.php: -------------------------------------------------------------------------------- 1 | 'show status', 19 | 'pgsql' => 'show status', 20 | 'sqlite' => 'show status', 21 | 'sqlsrv' => 'show status', 22 | ]; 23 | protected $tableSql = "SELECT Name as tablename FROM SysObjects WHERE XType='U' ORDER BY Name"; 24 | 25 | protected function __construct($config) 26 | { 27 | $this->config = $config; 28 | $host = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '') . '/' . ($config['database'] ? "{$config['database']}" : ''); 29 | $host = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : ''); 30 | // 创建数据库连接对象 31 | $this->conn = new \MongoDB\Driver\Manager($host); 32 | } 33 | 34 | public static function getInstance($config) 35 | { 36 | if (null === self::$instance) { 37 | self::$instance = new self($config); 38 | } 39 | return self::$instance; 40 | } 41 | 42 | // 发送sql语句 43 | public function query($sql ) 44 | { 45 | return "请使用mongoQuery()"; 46 | } 47 | 48 | public function mongoQuery($table ,$filter ,$options) 49 | { 50 | // try{ 51 | //此处如果密码错误会报错 52 | $query = new \MongoDB\Driver\Query($filter , $options); 53 | // 执行查询 成功即连接成功 失败则失败 54 | $datas = $this->conn->executeQuery($table,$query)->toArray(); 55 | //返回数据 56 | return $datas; 57 | // }catch (\Exception $e) { 58 | // return '查询失败'; 59 | // } 60 | 61 | } 62 | 63 | // // 测试连接 64 | public function testConnection() 65 | { 66 | return $this->conn; 67 | } 68 | 69 | 70 | // 获取字段 71 | public function getFields($tableName) 72 | { 73 | dump($tableName); 74 | 75 | } 76 | 77 | // 获取表 78 | public function getTables() 79 | { 80 | // 待定 81 | return []; 82 | } 83 | 84 | // 性能语句分析 85 | public function getExplain($sql){} 86 | 87 | } 88 | -------------------------------------------------------------------------------- /extend/datasource/Oracle.php: -------------------------------------------------------------------------------- 1 | config = $config; 21 | $hostname = $config['hostname'].'/'.$config['dbname']; 22 | $this->conn = oci_connect($config['username'], $config['password'], $hostname, 'utf8'); 23 | } 24 | 25 | public static function getInstance($config) 26 | { 27 | if (null === self::$instance) { 28 | self::$instance = new self($config); 29 | } 30 | return self::$instance; 31 | } 32 | 33 | // 发送sql语句 34 | public function query($sql) 35 | { 36 | try { 37 | $ora = oci_parse($this->conn, $sql); 38 | oci_execute($ora, OCI_DEFAULT); 39 | $data = []; 40 | while($r = oci_fetch_assoc($ora)) { 41 | foreach($r as &$v) { 42 | if(is_resource($v)) { 43 | $v = stream_get_contents($v); 44 | } 45 | } 46 | $data[] = $r; 47 | } 48 | return $data; 49 | } catch (\Exception $e) { 50 | return false; 51 | } 52 | } 53 | 54 | // // 测试连接 55 | public function testConnection() 56 | { 57 | if (!$this->conn) return false; 58 | return [$this->config['dbname']]; 59 | } 60 | 61 | 62 | // 获取字段 63 | public function getFields($tableName){} 64 | 65 | // 获取表 66 | public function getTables() 67 | { 68 | $sql = $this->tableSql; 69 | $result = $this->query($sql); 70 | if (!$result) return false; 71 | foreach ($result as &$value) { 72 | $value = array_values($value); 73 | } 74 | return $result; 75 | } 76 | 77 | public function __destruct() 78 | { 79 | return oci_close($this->conn); 80 | } 81 | 82 | // // 获取表所有数据 83 | public function selectTables($tableName) 84 | { 85 | return $this->query("select * from " . $tableName); 86 | } 87 | 88 | // 性能语句分析 89 | public function getExplain($sql){} 90 | 91 | } 92 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Options +FollowSymlinks -Multiviews 3 | RewriteEngine On 4 | RewriteCond %{REQUEST_FILENAME} !-d 5 | RewriteCond %{REQUEST_FILENAME} !-f 6 | RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L] 7 | -------------------------------------------------------------------------------- /public/ConvertIpNew.php: -------------------------------------------------------------------------------- 1 | fp=0; 12 | if(($this->fp=@fopen($filename,"rb"))!==false){ 13 | $this->firstip=$this->getlong(); 14 | $this->lastip=$this->getlong(); 15 | $this->totalip=($this->lastip-$this->firstip)/7; 16 | register_shutdown_function(array(&$this,"__destruct")); 17 | } 18 | } 19 | 20 | public function __destruct(){ 21 | if($this->fp){ 22 | @fclose($this->fp); 23 | } 24 | $this->fp=0; 25 | } 26 | 27 | private function getlong(){ 28 | $result=unpack("Vlong",fread($this->fp,4)); 29 | return $result["long"]; 30 | } 31 | 32 | private function getlong3(){ 33 | $result=unpack("Vlong",fread($this->fp,3).chr(0)); 34 | return $result["long"]; 35 | } 36 | 37 | private function packip($ip){ 38 | return pack("N",intval(ip2long($ip))); 39 | } 40 | 41 | private function getstring($data=""){ 42 | $char=fread($this->fp,1); 43 | while(ord($char)>0){ 44 | $data.=$char; 45 | $char=fread($this->fp,1); 46 | } 47 | return $data; 48 | } 49 | 50 | private function getarea(){ 51 | $byte=fread($this->fp,1); 52 | switch(ord($byte)){ 53 | case 0: 54 | $operators=""; 55 | break; 56 | case 1: 57 | case 2: 58 | fseek($this->fp,$this->getlong3()); 59 | $operators=$this->getstring(); 60 | break; 61 | default: 62 | $operators=$this->getstring($byte); 63 | break;} 64 | return $operators; 65 | } 66 | 67 | public function getlocation($ip){ 68 | if(!$this->fp){return null;} 69 | $location["ip"]=gethostbyname($ip); 70 | $ip=$this->packip($location["ip"]); 71 | $l=0; 72 | $u=$this->totalip; 73 | $findip=$this->lastip; 74 | while($l<=$u){ 75 | $i=floor(($l+$u)/2); 76 | fseek($this->fp,$this->firstip+$i*7); 77 | $startip=strrev(fread($this->fp,4)); 78 | if($ip<$startip){ 79 | $u=$i-1; 80 | }else{ 81 | fseek($this->fp,$this->getlong3()); 82 | $endip=strrev(fread($this->fp,4)); 83 | if($ip>$endip){ 84 | $l=$i+1; 85 | }else{ 86 | $findip=$this->firstip+$i*7; 87 | break; 88 | } 89 | } 90 | } 91 | fseek($this->fp,$findip); 92 | $location["startip"]=long2ip($this->getlong()); 93 | $offset=$this->getlong3(); 94 | fseek($this->fp,$offset); 95 | $location["endip"]=long2ip($this->getlong()); 96 | $byte=fread($this->fp,1); 97 | switch(ord($byte)){ 98 | case 1: 99 | $countryOffset=$this->getlong3(); 100 | fseek($this->fp,$countryOffset); 101 | $byte=fread($this->fp,1); 102 | switch(ord($byte)){ 103 | case 2: 104 | fseek($this->fp,$this->getlong3()); 105 | $location["area"]=$this->getstring(); 106 | fseek($this->fp,$countryOffset+4); 107 | $location["operators"]=$this->getarea(); 108 | break; 109 | default: 110 | $location["area"]=$this->getstring($byte); 111 | $location["operators"]=$this->getarea(); 112 | break;} 113 | break; 114 | case 2: 115 | fseek($this->fp,$this->getlong3()); 116 | $location["area"]=$this->getstring(); 117 | fseek($this->fp,$offset+8); 118 | $location["operators"]=$this->getarea(); 119 | break; 120 | default: 121 | $location["area"]=$this->getstring($byte); 122 | $location["operators"]=$this->getarea(); 123 | break;} 124 | if($location["area"]=="CZ88.NET"){ 125 | $location["area"]="未知"; 126 | } 127 | if($location["operators"]=="CZ88.NET"){ 128 | $location["operators"]="未知"; 129 | } 130 | return $location; 131 | } 132 | } 133 | 134 | -------------------------------------------------------------------------------- /public/Cover/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /public/KindEditor/attached/1.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openBI-kwc/openBI/230f9dfe4324d708b440406c71bb7fc72d5456f8/public/KindEditor/attached/1.php -------------------------------------------------------------------------------- /public/KindEditor/upload_json.php: -------------------------------------------------------------------------------- 1 | array('gif', 'jpg', 'jpeg', 'png', 'bmp'), 28 | 'flash' => array('swf', 'flv'), 29 | 'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'), 30 | 'file' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2'), 31 | ); 32 | //最大文件大小 33 | $max_size = 1000000; 34 | 35 | $save_path = realpath($save_path) . '/'; 36 | 37 | //PHP上传失败 38 | if (!empty($_FILES['imgFile']['error'])) { 39 | switch($_FILES['imgFile']['error']){ 40 | case '1': 41 | $error = '超过php.ini允许的大小。'; 42 | break; 43 | case '2': 44 | $error = '超过表单允许的大小。'; 45 | break; 46 | case '3': 47 | $error = '图片只有部分被上传。'; 48 | break; 49 | case '4': 50 | $error = '请选择图片。'; 51 | break; 52 | case '6': 53 | $error = '找不到临时目录。'; 54 | break; 55 | case '7': 56 | $error = '写文件到硬盘出错。'; 57 | break; 58 | case '8': 59 | $error = 'File upload stopped by extension。'; 60 | break; 61 | case '999': 62 | default: 63 | $error = '未知错误。'; 64 | } 65 | alert($error); 66 | } 67 | 68 | //有上传文件时 69 | if (empty($_FILES) === false) { 70 | //原文件名 71 | $file_name = $_FILES['imgFile']['name']; 72 | //服务器上临时文件名 73 | $tmp_name = $_FILES['imgFile']['tmp_name']; 74 | //文件大小 75 | $file_size = $_FILES['imgFile']['size']; 76 | //检查文件名 77 | if (!$file_name) { 78 | alert("请选择文件。"); 79 | } 80 | //检查目录 81 | if (@is_dir($save_path) === false) { 82 | alert("上传目录不存在。"); 83 | } 84 | //检查目录写权限 85 | if (@is_writable($save_path) === false) { 86 | alert("上传目录没有写权限。"); 87 | } 88 | //检查是否已上传 89 | if (@is_uploaded_file($tmp_name) === false) { 90 | alert("上传失败。"); 91 | } 92 | //检查文件大小 93 | if ($file_size > $max_size) { 94 | alert("上传文件大小超过限制。"); 95 | } 96 | //检查目录名 97 | $dir_name = empty($_GET['dir']) ? 'image' : trim($_GET['dir']); 98 | if (empty($ext_arr[$dir_name])) { 99 | alert("目录名不正确。"); 100 | } 101 | //获得文件扩展名 102 | $temp_arr = explode(".", $file_name); 103 | $file_ext = array_pop($temp_arr); 104 | $file_ext = trim($file_ext); 105 | $file_ext = strtolower($file_ext); 106 | //检查扩展名 107 | if (in_array($file_ext, $ext_arr[$dir_name]) === false) { 108 | alert("上传文件扩展名是不允许的扩展名。\n只允许" . implode(",", $ext_arr[$dir_name]) . "格式。"); 109 | } 110 | //创建文件夹 111 | if ($dir_name !== '') { 112 | $save_path .= $dir_name . "/"; 113 | $save_url .= $dir_name . "/"; 114 | if (!file_exists($save_path)) { 115 | mkdir($save_path); 116 | } 117 | } 118 | $ymd = date("Ymd"); 119 | $save_path .= $ymd . "/"; 120 | $save_url .= $ymd . "/"; 121 | if (!file_exists($save_path)) { 122 | mkdir($save_path); 123 | } 124 | //新文件名 125 | $new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext; 126 | //移动文件 127 | $file_path = $save_path . $new_file_name; 128 | if (move_uploaded_file($tmp_name, $file_path) === false) { 129 | alert("上传文件失败。"); 130 | } 131 | @chmod($file_path, 0644); 132 | $file_url = $save_url . $new_file_name; 133 | 134 | header('Content-type: text/html; charset=UTF-8'); 135 | $json = new Services_JSON(); 136 | echo $json->encode(array('error' => 0, 'url' => $file_url)); 137 | exit; 138 | } 139 | 140 | function alert($msg) { 141 | header('Content-type: text/html; charset=UTF-8'); 142 | $json = new Services_JSON(); 143 | echo $json->encode(array('error' => 1, 'message' => $msg)); 144 | exit; 145 | } 146 | -------------------------------------------------------------------------------- /public/alg/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /public/api.php: -------------------------------------------------------------------------------- 1 | 50) $len = 50; 8 | 9 | for ($i=1; $i < $len+1; $i++) { 10 | $arr[$i - 1]['name'] = '测试名称' . $i; 11 | $arr[$i - 1]['value'] = mt_rand(10000, 10000000) / 100; 12 | $arr[$i - 1]['time'] = date('m-d', strtotime('-'.$i.' day')); 13 | } 14 | 15 | $json = json_encode($arr, JSON_UNESCAPED_UNICODE); 16 | 17 | exit($json); -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // [ 应用入口文件 ] 13 | // [ test ] 14 | // 指定允许其他域名访问 15 | // header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT,DELETE'); 16 | // header('Access-Control-Allow-Origin: * '); 17 | // header("Access-Control-Allow-Headers:token,Content-type"); 18 | // header('content-type:application/json;charset=utf8'); 19 | //header('Access-Control-Max-Age: 86400'); 20 | 21 | // 定义应用目录 22 | define('APP_PATH', __DIR__ . '/../application/'); 23 | 24 | // 加载框架引导文件 25 | require __DIR__ . '/../thinkphp/start.php'; 26 | 27 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/router.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | // $Id$ 12 | 13 | if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["REQUEST_URI"])) { 14 | return false; 15 | } else { 16 | require __DIR__ . "/index.php"; 17 | } 18 | -------------------------------------------------------------------------------- /public/static/css/wd.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | } 5 | 6 | body { 7 | width: 100vw; 8 | height: 100vh; 9 | overflow: hidden; 10 | } 11 | 12 | .screen { 13 | width: 100vw; 14 | height: 100vh; 15 | max-height: 2666px; 16 | background-size: 16px 16px; 17 | overflow: hidden; 18 | } 19 | 20 | .nav { 21 | height: 40px; 22 | background: #2a303c; 23 | font-size: 1.875rem; 24 | overflow: hidden; 25 | display: flex; 26 | } 27 | 28 | .nav_left { 29 | flex: 2; 30 | } 31 | 32 | .nav_right { 33 | flex: 2; 34 | } 35 | 36 | .nav_box { 37 | flex: 6; 38 | height: 40px; 39 | justify-content: center; 40 | } 41 | 42 | .nav_box img { 43 | width: 8.17vw; 44 | height: 20px; 45 | margin-left: 6px; 46 | margin-top: 10px; 47 | } 48 | 49 | .content { 50 | width: 100vw; 51 | overflow: hidden; 52 | display: flex; 53 | padding-top: 3.41vh; 54 | /*padding-bottom: 4.41vh;*/ 55 | background: #f8f9fd; 56 | } 57 | 58 | .conLfet { 59 | flex: 2; 60 | } 61 | 62 | .conright { 63 | flex: 2; 64 | } 65 | 66 | .contentBox { 67 | display: 6; 68 | width: 59.27vw; 69 | height: 77vh; 70 | overflow: hidden; 71 | } 72 | 73 | .row_y { 74 | /*display: flex;*/ 75 | float: left; 76 | width: 100%; 77 | height: 100%; 78 | overflow: hidden; 79 | } 80 | /*.row_h { 81 | display: flex; 82 | width: 100%; 83 | height: 31.6%; 84 | margin-top: 0.9%; 85 | overflow: hidden; 86 | }*/ 87 | 88 | .box { 89 | /*flex: 1.5;*/ 90 | float: left; 91 | width: 23.1%; 92 | height: 31.6%; 93 | background: #fff; 94 | overflow: hidden; 95 | border: 1px solid #ccc; 96 | margin-top: 0.9%; 97 | } 98 | 99 | .box_e { 100 | /*flex: 1.5;*/ 101 | width: 23.1%; 102 | float: left; 103 | height: 45.2%; 104 | background: #fff; 105 | overflow: hidden; 106 | border: 1px solid #ccc; 107 | margin-left: 1.5%; 108 | margin-top: 2.9%; 109 | } 110 | 111 | .box img { 112 | width: 100%; 113 | height: 62%; 114 | margin-top: 1px; 115 | } 116 | 117 | .box_e img { 118 | width: 100%; 119 | height: 52%; 120 | margin-top: 1px; 121 | } 122 | 123 | .boxOne { 124 | font-size: 1rem; 125 | margin-left: 6%; 126 | } 127 | 128 | .boxTwo { 129 | float: right; 130 | margin-top: 20%; 131 | margin-right: 12%; 132 | font-size: .5rem; 133 | color: #ccc; 134 | } 135 | 136 | .page { 137 | width: 100%; 138 | height: 4.41vh; 139 | background: #f8f9fd; 140 | } 141 | 142 | 143 | 144 | .footer { 145 | width: 100vw; 146 | height: 480px; 147 | background: url(../img/Oval.png); 148 | background-size: 100% 100%; 149 | } 150 | .masking{ 151 | opacity: 0.6; 152 | } 153 | 154 | 155 | /*分页*/ 156 | .pagination ul { 157 | list-style: none; 158 | padding-left: 0; 159 | width: 100%; 160 | text-align: center; 161 | } 162 | 163 | .pagination ul li { 164 | padding: 0 10px; 165 | vertical-align: top; 166 | display: inline-block; 167 | font-size: 14px; 168 | min-width: 36px; 169 | min-height: 28px; 170 | line-height: 28px; 171 | cursor: pointer; 172 | box-sizing: border-box; 173 | text-align: center; 174 | background-color: #fff; 175 | color: #606266; 176 | border-radius: 6px; 177 | margin: 0 1px; 178 | border: 1px solid #ebebeb; 179 | height: 30px 180 | } 181 | 182 | .pagination ul li:hover { 183 | transform: scale(1.1); 184 | background-color: #f4f6f8 185 | } 186 | 187 | .pagination li.active { 188 | background: #98a6ad; 189 | color: #fff; 190 | cursor: not-allowed 191 | } 192 | 193 | .pagination li.disabled { 194 | cursor: not-allowed 195 | } 196 | 197 | .pagination li.totalPage { 198 | background: 0 0; 199 | cursor: default; 200 | border: 0; 201 | padding: 0 6px 202 | } 203 | 204 | .pagination li.totalPage:hover { 205 | transform: none; 206 | background-color: #fff 207 | } 208 | 209 | .pagination li input { 210 | -webkit-appearance: none; 211 | background-color: #fff; 212 | background-image: none; 213 | border-radius: 4px; 214 | border: 1px solid #dcdfe6; 215 | box-sizing: border-box; 216 | color: #606266; 217 | display: inline-block; 218 | font-size: inherit; 219 | outline: 0; 220 | padding: 3px 5px; 221 | transition: border-color .2s cubic-bezier(.645, .045, .355, 1); 222 | width: 40px; 223 | height: 25px; 224 | margin: 0 6px 225 | } 226 | 227 | .pagination li input:focus { 228 | border-color: #98a6ad 229 | } 230 | 231 | .pagination { 232 | user-select: none 233 | } 234 | 235 | .pagination ul:nth-child(2) { 236 | border-radius: 6px 237 | } 238 | 239 | input[type=number] { 240 | -moz-appearance: textfield 241 | } 242 | 243 | input[type=number]::-webkit-inner-spin-button, 244 | input[type=number]::-webkit-outer-spin-button { 245 | -webkit-appearance: none; 246 | margin: 0 247 | } -------------------------------------------------------------------------------- /public/static/img/Oval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openBI-kwc/openBI/230f9dfe4324d708b440406c71bb7fc72d5456f8/public/static/img/Oval.png -------------------------------------------------------------------------------- /public/static/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openBI-kwc/openBI/230f9dfe4324d708b440406c71bb7fc72d5456f8/public/static/img/logo.png -------------------------------------------------------------------------------- /public/static/img/medical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openBI-kwc/openBI/230f9dfe4324d708b440406c71bb7fc72d5456f8/public/static/img/medical.png -------------------------------------------------------------------------------- /public/static/js/my.js: -------------------------------------------------------------------------------- 1 | var mak = document.querySelector(".mak"); 2 | 3 | mak.onmousemove = function(){ 4 | this.className = "masking"; 5 | // this.href = "#"; 6 | }; 7 | mak.onmouseout = function(){ 8 | this.className = ""; 9 | }; 10 | 11 | 12 | 13 | window.onload = function () { 14 | new Page({ 15 | id: 'pagination', 16 | pageTotal: 20, //必填,总页数 17 | pageAmount: 10, //每页多少条 18 | dataTotal: 500, //总共多少条数据 19 | curPage:1, //初始页码,不填默认为1 20 | pageSize: 5, //分页个数,不填默认为5 21 | showPageTotalFlag:true, //是否显示数据统计,不填默认不显示 22 | showSkipInputFlag:true, //是否支持跳转,不填默认不显示 23 | getPage: function (page) { 24 | //获取当前页数 25 | console.log(page); 26 | } 27 | }) 28 | 29 | } 30 | function Page(_ref) { 31 | var pageSize = _ref.pageSize, 32 | pageTotal = _ref.pageTotal, 33 | curPage = _ref.curPage, 34 | id = _ref.id, 35 | getPage = _ref.getPage, 36 | showPageTotalFlag = _ref.showPageTotalFlag, 37 | showSkipInputFlag = _ref.showSkipInputFlag, 38 | pageAmount = _ref.pageAmount, 39 | dataTotal = _ref.dataTotal; 40 | if(!pageSize) { 41 | pageSize = 0 42 | }; 43 | if(!pageSize) { 44 | pageSize = 0 45 | }; 46 | if(!pageTotal) { 47 | pageTotal = 0 48 | }; 49 | if(!pageAmount) { 50 | pageAmount = 0 51 | }; 52 | if(!dataTotal) { 53 | dataTotal = 0 54 | }; 55 | this.pageSize = pageSize || 5; 56 | this.pageTotal = pageTotal; 57 | this.pageAmount = pageAmount; 58 | this.dataTotal = dataTotal; 59 | this.curPage = curPage || 1; 60 | this.ul = document.createElement('ul'); 61 | this.id = id; 62 | this.getPage = getPage; 63 | this.showPageTotalFlag = showPageTotalFlag || false; 64 | this.showSkipInputFlag = showSkipInputFlag || false; 65 | if(dataTotal > 0 && pageTotal > 0) { 66 | this.init(); 67 | } else { 68 | console.error("") 69 | } 70 | }; 71 | Page.prototype = { 72 | init: function init() { 73 | var pagination = document.getElementById(this.id); 74 | pagination.innerHTML = ''; 75 | this.ul.innerHTML = ''; 76 | pagination.appendChild(this.ul); 77 | var that = this; 78 | that.firstPage(); 79 | that.lastPage(); 80 | that.getPages().forEach(function(item) { 81 | var li = document.createElement('li'); 82 | if(item == that.curPage) { 83 | li.className = 'active'; 84 | } else { 85 | li.onclick = function() { 86 | that.curPage = parseInt(this.innerHTML); 87 | that.init(); 88 | that.getPage(that.curPage); 89 | }; 90 | } 91 | li.innerHTML = item; 92 | that.ul.appendChild(li); 93 | }); 94 | that.nextPage(); 95 | that.finalPage(); 96 | if(that.showSkipInputFlag) { 97 | that.showSkipInput(); 98 | } 99 | if(that.showPageTotalFlag) { 100 | that.showPageTotal(); 101 | } 102 | }, 103 | firstPage: function firstPage() { 104 | var that = this; 105 | var li = document.createElement('li'); 106 | li.innerHTML = '首页'; 107 | this.ul.appendChild(li); 108 | li.onclick = function() { 109 | var val = parseInt(1); 110 | that.curPage = val; 111 | that.getPage(that.curPage); 112 | that.init(); 113 | }; 114 | }, 115 | lastPage: function lastPage() { 116 | var that = this; 117 | var li = document.createElement('li'); 118 | li.innerHTML = '<'; 119 | if(parseInt(that.curPage) > 1) { 120 | li.onclick = function() { 121 | that.curPage = parseInt(that.curPage) - 1; 122 | that.init(); 123 | that.getPage(that.curPage); 124 | }; 125 | } else { 126 | li.className = 'disabled'; 127 | } 128 | this.ul.appendChild(li); 129 | }, 130 | 131 | getPages: function getPages() { 132 | var pag = []; 133 | if(this.curPage <= this.pageTotal) { 134 | if(this.curPage < this.pageSize) { 135 | var i = Math.min(this.pageSize, this.pageTotal); 136 | while(i) { 137 | pag.unshift(i--); 138 | } 139 | } else { 140 | var middle = this.curPage - Math.floor(this.pageSize / 2), 141 | i = this.pageSize; 142 | if(middle > this.pageTotal - this.pageSize) { 143 | middle = this.pageTotal - this.pageSize + 1; 144 | } 145 | while(i--) { 146 | pag.push(middle++); 147 | } 148 | } 149 | } else { 150 | console.error(''); 151 | } 152 | if(!this.pageSize) { 153 | console.error(''); 154 | } 155 | return pag; 156 | }, 157 | nextPage: function nextPage() { 158 | var that = this; 159 | var li = document.createElement('li'); 160 | li.innerHTML = '>'; 161 | if(parseInt(that.curPage) < parseInt(that.pageTotal)) { 162 | li.onclick = function() { 163 | that.curPage = parseInt(that.curPage) + 1; 164 | that.init(); 165 | that.getPage(that.curPage); 166 | }; 167 | } else { 168 | li.className = 'disabled'; 169 | } 170 | this.ul.appendChild(li); 171 | }, 172 | finalPage: function finalPage() { 173 | var that = this; 174 | var li = document.createElement('li'); 175 | li.innerHTML = '尾页'; 176 | this.ul.appendChild(li); 177 | li.onclick = function() { 178 | var yyfinalPage = that.pageTotal; 179 | var val = parseInt(yyfinalPage); 180 | that.curPage = val; 181 | that.getPage(that.curPage); 182 | that.init(); 183 | }; 184 | }, 185 | showSkipInput: function showSkipInput() { 186 | var that = this; 187 | var li = document.createElement('li'); 188 | li.className = 'totalPage'; 189 | var span1 = document.createElement('span'); 190 | span1.innerHTML = '跳转到'; 191 | li.appendChild(span1); 192 | var input = document.createElement('input'); 193 | input.setAttribute("type", "number"); 194 | input.onkeydown = function(e) { 195 | var oEvent = e || event; 196 | if(oEvent.keyCode == '13') { 197 | var val = parseInt(oEvent.target.value); 198 | if(typeof val === 'number' && val <= that.pageTotal && val > 0) { 199 | that.curPage = val; 200 | that.getPage(that.curPage); 201 | } else { 202 | alert("请输入正确的页数") 203 | } 204 | that.init(); 205 | } 206 | }; 207 | li.appendChild(input); 208 | var span2 = document.createElement('span'); 209 | span2.innerHTML = '页'; 210 | li.appendChild(span2); 211 | this.ul.appendChild(li); 212 | }, 213 | showPageTotal: function showPageTotal() { 214 | var that = this; 215 | var li = document.createElement('li'); 216 | li.innerHTML = '共 ' + that.pageTotal + ' 页'; 217 | li.className = 'totalPage'; 218 | this.ul.appendChild(li); 219 | 220 | } 221 | }; 222 | //滑入滑出 223 | 224 | -------------------------------------------------------------------------------- /public/uploads/logo/defualt/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openBI-kwc/openBI/230f9dfe4324d708b440406c71bb7fc72d5456f8/public/uploads/logo/defualt/logo.png -------------------------------------------------------------------------------- /public/uploads/staticimg/perview_avatar_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openBI-kwc/openBI/230f9dfe4324d708b440406c71bb7fc72d5456f8/public/uploads/staticimg/perview_avatar_1.png -------------------------------------------------------------------------------- /public/uploads/staticimg/perview_avatar_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openBI-kwc/openBI/230f9dfe4324d708b440406c71bb7fc72d5456f8/public/uploads/staticimg/perview_avatar_2.png -------------------------------------------------------------------------------- /public/uploads/staticimg/perview_avatar_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openBI-kwc/openBI/230f9dfe4324d708b440406c71bb7fc72d5456f8/public/uploads/staticimg/perview_avatar_3.png -------------------------------------------------------------------------------- /runtime/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /think: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 11 | // +---------------------------------------------------------------------- 12 | 13 | // 定义项目路径 14 | define('APP_PATH', __DIR__ . '/application/'); 15 | 16 | // 加载框架引导文件 17 | require __DIR__.'/thinkphp/console.php'; 18 | -------------------------------------------------------------------------------- /vendor/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore --------------------------------------------------------------------------------