From c158f219ba0612813a15baa2be4f01f0eff1ae1a Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 19:52:48 +0800 Subject: [PATCH 001/202] kun --- app/__init__.py | 3 +- app/config/app.py | 4 +- app/website/__init__.py | 1 + app/website/common/__init__.py | 2 + app/website/common/autoload.py | 47 +++ app/website/common/file/sqlite/.gitignore | 1 + app/website/controller/__init__.py | 2 + app/website/controller/index/__init__.py | 1 + .../controller/index/common/__init__.py | 4 + .../controller/index/common/autoload.py | 1 + .../index/common/file/sqlite/.gitignore | 1 + app/website/controller/index/common/model.py | 4 + app/website/controller/index/index.py | 6 + app/website/controller/index/install.txt | 1 + app/website/controller/index/pub.py | 275 ++++++++++++++++++ app/website/install.txt | 1 + kcweb/app.py | 54 ++-- kcweb/config/__init__.py | 3 +- 18 files changed, 390 insertions(+), 21 deletions(-) create mode 100644 app/website/__init__.py create mode 100644 app/website/common/__init__.py create mode 100644 app/website/common/autoload.py create mode 100644 app/website/common/file/sqlite/.gitignore create mode 100644 app/website/controller/__init__.py create mode 100644 app/website/controller/index/__init__.py create mode 100644 app/website/controller/index/common/__init__.py create mode 100644 app/website/controller/index/common/autoload.py create mode 100644 app/website/controller/index/common/file/sqlite/.gitignore create mode 100644 app/website/controller/index/common/model.py create mode 100644 app/website/controller/index/index.py create mode 100644 app/website/controller/index/install.txt create mode 100644 app/website/controller/index/pub.py create mode 100644 app/website/install.txt diff --git a/app/__init__.py b/app/__init__.py index ed8d0eb..8d6b335 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- # #导入模块 -from . import intapp \ No newline at end of file +from . import intapp +from . import website \ No newline at end of file diff --git a/app/config/app.py b/app/config/app.py index 12b5867..8b4b60b 100644 --- a/app/config/app.py +++ b/app/config/app.py @@ -43,8 +43,8 @@ mongo['retryWrites']=False #是否支持重新写入 #路由配置 route['default']=True #是否开启默认路由 默认路由开启后面不影响以下配置的路由,模块名/版本名/控制器文件名/方法名 作为路由地址 如:http://www.kcw.com/modular/plug/index/index/ -route['modular']='' #指定访问配置固定模块 (如果配置了该值,将无法通过改变url访问不同模块) -route['plug']='' #指定访问固定插件 (如果配置了该值,将无法通过改变url访问不同插件) +route['modular']=[{"192":"website"},{"www":"website"}] #指定访问配置固定模块 (如果匹配了该值,将无法通过改变url访问不同模块) +route['plug']=[{"192":"index"},{"www":"index"}] #指定访问固定插件 (如果匹配了该值,将无法通过改变url访问不同插件) route['defmodular']='intapp' #默认模块 当url不包括模块名时 route['defplug']='index' #默认插件 当url不包括插件名时 route['files']='index' #默认路由文件(控制器) 当url不包括控制器名时 diff --git a/app/website/__init__.py b/app/website/__init__.py new file mode 100644 index 0000000..72f4562 --- /dev/null +++ b/app/website/__init__.py @@ -0,0 +1 @@ +from . import controller \ No newline at end of file diff --git a/app/website/common/__init__.py b/app/website/common/__init__.py new file mode 100644 index 0000000..6b23e23 --- /dev/null +++ b/app/website/common/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from .autoload import * \ No newline at end of file diff --git a/app/website/common/autoload.py b/app/website/common/autoload.py new file mode 100644 index 0000000..36a177e --- /dev/null +++ b/app/website/common/autoload.py @@ -0,0 +1,47 @@ +from app.common import * +import copy,hmac +db_core=copy.deepcopy(config.database) +db_core['type']='mysql' +db_core['host']=['127.0.0.1'] +db_core['port']=[3306] +db_core['user']=['root'] +db_core['password']=['intapppasswordtest'] +db_core['db']=['core'] +db_core_file=copy.deepcopy(db_core) +db_core_file['db']=['core_file'] +db_core_ims=copy.deepcopy(db_core) +db_core_ims['db']=['core_ims'] +db_core_kcweb=copy.deepcopy(db_core) +db_core_kcweb['db']=['core_kcweb'] +def isemail(email): + ex_email = re.compile(r'^[1-9][0-9]{4,10}@qq\.com') + result = ex_email.match(email) + if result: + return True + else: + return False +def isphone(phone): + if len(phone)==11: + return True + else: + return False +class AlOss2: + accessKeyId="" + accessKeySecret='' + data=[] + def __init(): + AlOss2.accessKeyId = "LTAISSz1gBwL1oOo" + AlOss2.accessKeySecret = "MoGi9FusUZx6Vjp8FgLrRkxU22kFON" + def Signatureurl(objects,bucket,jurisdiction=''): + AlOss2.__init() + if jurisdiction=='private' or jurisdiction=='bucket': + # ak=AlOss2.accessKeyId + # sk=AlOss2.accessKeySecret + # expire=time()+3600*7 + # StringToSign="GET\n\n\n"+expire+"\n/"+bucket+"/"+objects + # Sign=base64_encode(hash_hmac("sha1",StringToSign,sk,true)) + # url=urlencode(objects)."?OSSAccessKeyId=".$ak."&Expires=".$expire."&Signature=".urlencode($Sign) + url=objects + else: + url=objects + return url \ No newline at end of file diff --git a/app/website/common/file/sqlite/.gitignore b/app/website/common/file/sqlite/.gitignore new file mode 100644 index 0000000..0179ab1 --- /dev/null +++ b/app/website/common/file/sqlite/.gitignore @@ -0,0 +1 @@ +intapp \ No newline at end of file diff --git a/app/website/controller/__init__.py b/app/website/controller/__init__.py new file mode 100644 index 0000000..6a03892 --- /dev/null +++ b/app/website/controller/__init__.py @@ -0,0 +1,2 @@ + +from . import index \ No newline at end of file diff --git a/app/website/controller/index/__init__.py b/app/website/controller/index/__init__.py new file mode 100644 index 0000000..3471b9b --- /dev/null +++ b/app/website/controller/index/__init__.py @@ -0,0 +1 @@ +from . import index \ No newline at end of file diff --git a/app/website/controller/index/common/__init__.py b/app/website/controller/index/common/__init__.py new file mode 100644 index 0000000..42e846d --- /dev/null +++ b/app/website/controller/index/common/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from .model import * +def before_request(): + pass \ No newline at end of file diff --git a/app/website/controller/index/common/autoload.py b/app/website/controller/index/common/autoload.py new file mode 100644 index 0000000..a0fd77e --- /dev/null +++ b/app/website/controller/index/common/autoload.py @@ -0,0 +1 @@ +from app.website.common import * \ No newline at end of file diff --git a/app/website/controller/index/common/file/sqlite/.gitignore b/app/website/controller/index/common/file/sqlite/.gitignore new file mode 100644 index 0000000..72a3e83 --- /dev/null +++ b/app/website/controller/index/common/file/sqlite/.gitignore @@ -0,0 +1 @@ +intappindex \ No newline at end of file diff --git a/app/website/controller/index/common/model.py b/app/website/controller/index/common/model.py new file mode 100644 index 0000000..2a89589 --- /dev/null +++ b/app/website/controller/index/common/model.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from .autoload import * +# 可以在这里初始化数据库 +model_api_index_path=os.path.split(os.path.realpath(__file__))[0]+"/file/sqlite/intappindex" #数据存放目录 diff --git a/app/website/controller/index/index.py b/app/website/controller/index/index.py new file mode 100644 index 0000000..0964a08 --- /dev/null +++ b/app/website/controller/index/index.py @@ -0,0 +1,6 @@ +from .common import * +def index(): + data={ + "name":"kcweb" + } + return successjson(data) diff --git a/app/website/controller/index/install.txt b/app/website/controller/index/install.txt new file mode 100644 index 0000000..fde6665 --- /dev/null +++ b/app/website/controller/index/install.txt @@ -0,0 +1 @@ +kcweb \ No newline at end of file diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py new file mode 100644 index 0000000..c7276d3 --- /dev/null +++ b/app/website/controller/index/pub.py @@ -0,0 +1,275 @@ +from .common import * +def before_request(): + pass +def sebduser(): + "发送注册验证码" + username=request.args.get("username") + if(mysql("user",db_core).where("phone='"+username+"' or email='"+username+"'").count()): + return errorjson("该账号已注册") + value=get_cache(username+"reg") + ex=86400 + code=randoms(5) + if value: + if len(username)==11 and int(value['sendcount'])>10: + return errorjson("今日验证码发送次数上限,请明日再试") + if len(username)==11 and (times()-int(value['updtime'])<120): + return errorjson("验证码发送频率过高,请稍后再试") + if isemail(username) and (times()-int(value['updtime'])<30): + return errorjson("验证码发送频率过高,请稍后再试") + value={ + 'code':code, + "ex":120, + "sendcount":int(value['sendcount'])+1, + "addtime":value['addtime'], + "updtime":times() + } + ex=ex-(times()-int(value['addtime'])) + if(ex < 10): + ex=86400 + else: + value={ + 'code':code, + "ex":120, + "sendcount":1, + "addtime":times(), + "updtime":times() + } + } + if len(username)==11: + pass + # $send=new \app\common\util\phone\Phone(); + elif isemail(username): + pass + # $send=new \app\common\util\email\Email(); + # $send->theme="禄可联盟"; + # $send->title="注册验证码"; + else: + return errorjson("请输入正确的手机或邮箱") + # $send->addressee=$username; + # $send->content="【kcweb验证码】您正在注册kcweb一账通账号,本次验证码:{$code}"; + # if($send->send()){ + # set_cache($username."reg", $value,$ex); + # $this->successjson("发送成功"); + # }else{ + # return $this->errorjson("验证码发送失败,请稍后再试"); + # } + +def reg(): + "注册账号" + username=request.args.get("username") + code=request.args.get("code") + password=request.args.get("password") + if mysql("user",db_core).where("phone='"+username+"' or email='"+username+"'").count(): + return errorjson("该账号已注册") + value=get_cache(username+"reg") + if value: + if(times()-int(value['updtime'])<300): + if(code==value['code']): + data={} + if(isphone(username)): + data['phone']=username + else: + data['email']=username + + data['pwd']=md5(md5(password)) + data['nickname']=username + data['addtime']=times() + data['logintime']=times() + mysql("user",db_core).insert(data) + return successjson("注册成功") + else: + return errorjson("验证码错误") + else: + return errorjson("验证码已失效") + else: + return errorjson("验证码错误") +} + +def modular_list(): + "模块列表" + kw=request.args.get("kw") + pagenow=request.args.get("pagenow") + pagesize=request.args.get("pagesize") + if not pagesize: + pagesize=10 + if not pagenow: + pagenow=1 + where="is_examine=1" + if kw: + where+=" and (title LIKE '%{$kw}%' or name LIKE '%"+kw+"%')" + user={} + list=mysql('modular',db_core_kcweb).order("id desc").page(pagenow,pagesize).where(where).select() + iconurl=config.domain['kcwebfile'] + lists=[] + index=0 + for k in list: + lists.append(k) + lists[index]['icon']=iconurl+k['icon'] + lists[index]['url']='' + ation=[] + if (k['user_id'] <= 1000): + ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) + ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) + ation.append({"title":"官方认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfrz.png"}) + ation.append({"title":"审核已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsh.png"}) + ation.append({"title":"安全认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/anqrz.png"}) + if k['token']: + ation.append({"title":"该模块已上锁","describe":"","icon":config.domain['kcwebimg']+"/icon/sho1.png"}) + lists[index]['token']=True + else: + lists[index]['token']=False + + lists[index]['ation']=ation + nickname="" + for u in user: + if u==k['user_id']: + nickname=u + break + if not nickname: + user_info=mysql("user",db_core).field("nickname,img_head").find(k['user_id']) + user_info['img_head']=iconurl.user_info['img_head'] + user.append(user_info) + else: + user_info=nickname + + lists[index]['user']=user_info + index+=0 + count=mysql('modular',db_core_kcweb).where(where).count() + return successjson(return_list(lists,count,pagenow,pagesize)) + + +def plug_list(): + "插件列表" + kw=request.args.get("kw") + modular=request.args.get("modular") + pagenow=request.args.get("pagenow") + pagesize=request.args.get("pagesize") + group=request.args.get("group") + if not pagesize: + pagesize=10 + if not pagenow: + pagenow=1 + where="is_examine=1" + if kw: + where+=" and (title LIKE '"+kw+"%' or name LIKE '%"+kw+"%')" + if modular: + where+=" and modular = '"+modular+"'" + if group: + list=mysql('plug',db_core_kcweb).order("modular asc,id desc").group('name').page(pagenow,pagesize).where(where).select() + count=mysql('plug',db_core_kcweb).group('name').where(where).count() + else: + list=M('plug',db_core_kcweb).order("modular asc,id desc").page(pagenow,pagesize).where(where).select() + count=M('plug',db_core_kcweb).where(where).count() + iconurl=config.domain['kcwebfile'] + lists=[] + user=[] + index=0 + for k in list: + where="name='"+k['name']+"'" + if modular: + where+=" and modular = '"+modular+"'" + editionlist=mysql('plug',db_core_kcweb).order("edition desc").where(where).field("edition").limit(100).select() + edition=[] + for k1 in editionlist: + edition.append(k1['edition']) + lists[index]=k + lists[index]['icon']=iconurl+k['icon'] + lists[index]['url']='' + lists[index]['edition']=edition + ation=[] + if (k['user_id'] <= 1000): + ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) + ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) + ation.append({"title":"官方认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfrz.png"}) + ation.append({"title":"审核已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsh.png"}) + ation.append({"title":"安全认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/anqrz.png"}) + if k['token']: + ation.append({"title":"该模块已上锁","describe":"","icon":config.domain['kcwebimg']+"/icon/sho1.png"}) + lists[index]['token']=True + else: + lists[index]['token']=False + lists[index]['ation']=ation + nickname="" + for u in user: + if u==k['user_id']: + user.append(u) + nickname=u + break + if not nickname: + user_info=mysql("user").field("nickname,img_head").find(k['user_id']) + user_info['img_head']=iconurl.user_info['img_head'] + user[]=user_info + else: + user_info=nickname + lists[index]['user']=user_info + index+=1 + return successjson(return_list(lists,count,pagenow,pagesize)) + + +def modular(): + "获取模块" + name=request.args.get("name") + token=request.args.get("token") + data=mysql("modular",db_core_kcweb).where("name='"+name+"'").find() + if data: + if data['token']: + if data['token']!=token: + return errorjson('该模块需要授权码验证',-1) + url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['filename'],'fanshufile','private') + data['dowurl']=url + # mysql("modular",db_core_kcweb).where("name='{$name}'").inc('dow_num').update() + return successjson(data) + +def plug(modular,name,edition='',token=''){ + "获取插件" + modular=request.args.get("modular") + name=request.args.get("name") + edition=request.args.get("edition") + token=request.args.get("token") + where="modular ='"+modular+"' and name='"+name+"'" + if edition: + where+=" and edition='"+edition+"'" + data=mysql("plug",db_core_kcweb).where(where).order("addtime desc").find() + if data: + if data['token']: + if data['token']!=token: + return errorjson('该插件需要授权码验证',-1) + # $url=config("other.domain.ossfile").\app\common\Oss::Signatureurl($data['fileurl'],'fanshufile','private'); + url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['filename'],'fanshufile','private') + data['dowurl']=url + # mysql("plug",db_core_kcweb).where(where).inc('dow_num').update() + return successjson(data) + +def soft_list(){ + "软件列表" + where="" + kw=request.args.get("kw") + pagenow=request.args.get("pagenow") + pagesize=request.args.get("pagesize") + if not pagesize: + pagesize=10 + if not pagenow: + pagenow=1 + if kw: + where="title LIKE '"+kw+"'" + list=mysql('soft',db_core_kcweb).field("id,icon,title,edition,shell,describes,paths,filename,platform,updtime").order("id desc").page(pagenow,pagesize).where(where).select() + domain=config.domain['kcwebfile'] + lists=[] + i=0 + for k in list: + lists[i]=k + lists[i]['icon']=domain+"/"+k['icon'] + i+=1 + count=M('soft',db_core_kcweb).where(where).count() + return successjson(return_list(lists,count,pagenow,pagesize)) + +def soft_dow_url($id): + "获取软件下载地址" + data=mysql('soft',db_core_kcweb).where("id",id).find() + if data: + url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['filename'],'fanshufile','private') + data['dowurl']=url + # mysql('soft',db_core_kcweb).where("id",id).inc('dow_num').update() + return successjson(data) + else: + return errorjson("参数错误") diff --git a/app/website/install.txt b/app/website/install.txt new file mode 100644 index 0000000..fde6665 --- /dev/null +++ b/app/website/install.txt @@ -0,0 +1 @@ +kcweb \ No newline at end of file diff --git a/kcweb/app.py b/kcweb/app.py index 6f9e3c8..b4351af 100644 --- a/kcweb/app.py +++ b/kcweb/app.py @@ -145,19 +145,7 @@ class web: ) except KeyboardInterrupt: pass - def __get_modular(self,header): - "获取模块" - modular='' - route=self.__config.route - if route['modular']: - if isinstance(route['modular'],str): - modular=route['modular'] - else: - HTTP_HOST=header['HTTP_HOST'].split(".")[0] - for mk in route['modular']: - if HTTP_HOST in mk: - modular=mk[HTTP_HOST] - return modular + def __getconfigroute(self,PATH_INFO,header): "使用配置路由" route=self.__config.route @@ -195,10 +183,38 @@ class web: break except:pass return routedefault,PATH_INFO + def __get_modular(self,header): + "获取模块" + modular='' + route=self.__config.route + if route['modular']: + if isinstance(route['modular'],str): + modular=route['modular'] + else: + HTTP_HOST=header['HTTP_HOST'].split(".")[0] + for mk in route['modular']: + if HTTP_HOST in mk: + modular=mk[HTTP_HOST] + return modular + def __get_plug(self,header): + "获取插件" + plug='' + route=self.__config.route + if route['plug']: + if isinstance(route['plug'],str): + plug=route['plug'] + else: + HTTP_HOST=header['HTTP_HOST'].split(".")[0] + for mk in route['plug']: + if HTTP_HOST in mk: + plug=mk[HTTP_HOST] + return plug def defaultroute(self,header,PATH_INFO): "路由匹配" route=self.__config.route modular=web.__get_modular(self,header) + if route['plug']: + getplug=web.__get_plug(self,header) routedefault=route['default'] methods=route['methods'] if routedefault: @@ -216,8 +232,10 @@ class web: ##默认路由start ################################################################################# if modular: - if route['plug']: #匹配模块并且匹配了插件 - plug=route['plug'] + # if route['plug']: #匹配模块并且匹配了插件 + # plug=route['plug'] + if getplug: + plug=getplug routedefault,PATH_INFO=web.__getconfigroute( self, PATH_INFO, @@ -255,8 +273,10 @@ class web: else: param.append(urllib.parse.unquote(path)) i+=1 - elif route['plug']: #配置版本的但没有匹配插件 - plug=route['plug'] + # elif route['plug']: #配置模块但没有匹配插件 + # plug=route['plug'] + if getplug: + plug=getplug routedefault,PATH_INFO=web.__getconfigroute( self, PATH_INFO, diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index 8734767..1f81ff1 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -116,7 +116,8 @@ domain={} domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" -domain['kcwebapi']="https://kcweb.kwebapp.cn" +# domain['kcwebapi']="https://kcweb.kwebapp.cn" +domain['kcwebapi']="https://intapp.kwebapp.cn/website" #其他配置 other={} -- Gitee From a9bcc48f79065cea2092caef898aa45be6e355a0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:06:25 +0800 Subject: [PATCH 002/202] kun --- kcweb/config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index 1f81ff1..3930e80 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -116,8 +116,8 @@ domain={} domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" -# domain['kcwebapi']="https://kcweb.kwebapp.cn" -domain['kcwebapi']="https://intapp.kwebapp.cn/website" +domain['kcwebapi']="https://kcweb.kwebapp.cn" +# domain['kcwebapi']="https://intapp.kwebapp.cn/website" #其他配置 other={} -- Gitee From c5ca62c21a96b14039d3efa3a33cf63163fadc29 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:14:09 +0800 Subject: [PATCH 003/202] kun --- app/website/controller/index/__init__.py | 3 ++- app/website/controller/index/pub.py | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/website/controller/index/__init__.py b/app/website/controller/index/__init__.py index 3471b9b..4536cad 100644 --- a/app/website/controller/index/__init__.py +++ b/app/website/controller/index/__init__.py @@ -1 +1,2 @@ -from . import index \ No newline at end of file +from . import index +from . import pub \ No newline at end of file diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index c7276d3..ea6f4d8 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -34,7 +34,6 @@ def sebduser(): "addtime":times(), "updtime":times() } - } if len(username)==11: pass # $send=new \app\common\util\phone\Phone(); @@ -83,8 +82,6 @@ def reg(): return errorjson("验证码已失效") else: return errorjson("验证码错误") -} - def modular_list(): "模块列表" kw=request.args.get("kw") -- Gitee From f74424e63c454cec5ba19e5eb2b45f899d23f7b6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:15:31 +0800 Subject: [PATCH 004/202] kun --- app/website/controller/index/pub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index ea6f4d8..e4bab94 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -195,7 +195,7 @@ def plug_list(): if not nickname: user_info=mysql("user").field("nickname,img_head").find(k['user_id']) user_info['img_head']=iconurl.user_info['img_head'] - user[]=user_info + user.append(user_info) else: user_info=nickname lists[index]['user']=user_info -- Gitee From 4d353d97085b6a93c693908c6e9c2a72b4262844 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:15:53 +0800 Subject: [PATCH 005/202] kun --- app/website/controller/index/pub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index e4bab94..11ce7fc 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -217,7 +217,7 @@ def modular(): # mysql("modular",db_core_kcweb).where("name='{$name}'").inc('dow_num').update() return successjson(data) -def plug(modular,name,edition='',token=''){ +def plug(modular,name,edition='',token=''): "获取插件" modular=request.args.get("modular") name=request.args.get("name") -- Gitee From 6fbd9c22df9e2ca274d78516dd3e00df4a6c8a2f Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:16:13 +0800 Subject: [PATCH 006/202] kun --- app/website/controller/index/pub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 11ce7fc..6b83beb 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -228,7 +228,7 @@ def plug(modular,name,edition='',token=''): where+=" and edition='"+edition+"'" data=mysql("plug",db_core_kcweb).where(where).order("addtime desc").find() if data: - if data['token']: + if data['token']: if data['token']!=token: return errorjson('该插件需要授权码验证',-1) # $url=config("other.domain.ossfile").\app\common\Oss::Signatureurl($data['fileurl'],'fanshufile','private'); -- Gitee From 3a87aca3de6efabe6d333ad0f5c05bc511dabc29 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:16:32 +0800 Subject: [PATCH 007/202] kun --- app/website/controller/index/pub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 6b83beb..acc82a0 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -237,7 +237,7 @@ def plug(modular,name,edition='',token=''): # mysql("plug",db_core_kcweb).where(where).inc('dow_num').update() return successjson(data) -def soft_list(){ +def soft_list(): "软件列表" where="" kw=request.args.get("kw") -- Gitee From 45ac2387fdad9b83ce51bd63b36011eadcfc6e80 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:16:53 +0800 Subject: [PATCH 008/202] kun --- app/website/controller/index/pub.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index acc82a0..4fa3d3c 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -260,8 +260,9 @@ def soft_list(): count=M('soft',db_core_kcweb).where(where).count() return successjson(return_list(lists,count,pagenow,pagesize)) -def soft_dow_url($id): +def soft_dow_url(): "获取软件下载地址" + id=request.args.get("id") data=mysql('soft',db_core_kcweb).where("id",id).find() if data: url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['filename'],'fanshufile','private') -- Gitee From 171a538cb240cd2469778b52af9b6ef411112129 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:23:45 +0800 Subject: [PATCH 009/202] kun --- app/intapp/controller/index/modular.py | 3 ++- kcweb/config/__init__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/intapp/controller/index/modular.py b/app/intapp/controller/index/modular.py index 561a24e..457db3e 100644 --- a/app/intapp/controller/index/modular.py +++ b/app/intapp/controller/index/modular.py @@ -37,9 +37,10 @@ def banduser(): def modular_list(kw='',pagenow=1): http=Http() - http.openurl(config.domain['kcwebapi']+"/pub/modular_list","POST",{ + http.openurl(config.domain['kcwebapi']+"/pub/modular_list","get",{ "kw":kw,"pagenow":pagenow }) + print(http.get_text) res=json_decode(http.get_text) del http lists=res['data']['lists'] diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index 3930e80..00138aa 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -117,7 +117,7 @@ domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" domain['kcwebapi']="https://kcweb.kwebapp.cn" -# domain['kcwebapi']="https://intapp.kwebapp.cn/website" +# domain['kcwebapi']="https://intapp.kwebapp.cn/website/index" #其他配置 other={} -- Gitee From 6beb0f73dba74029c0ddf88fdee9fb6d5b13abc5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:24:53 +0800 Subject: [PATCH 010/202] kun --- app/website/controller/index/pub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 4fa3d3c..923404f 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -94,7 +94,7 @@ def modular_list(): where="is_examine=1" if kw: where+=" and (title LIKE '%{$kw}%' or name LIKE '%"+kw+"%')" - user={} + user=[] list=mysql('modular',db_core_kcweb).order("id desc").page(pagenow,pagesize).where(where).select() iconurl=config.domain['kcwebfile'] lists=[] -- Gitee From 4a461af3f0f2ee0a66c9d2977dfa49efb24a53f5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 20:35:05 +0800 Subject: [PATCH 011/202] kun --- app/website/common/autoload.py | 2 +- app/website/controller/index/pub.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/website/common/autoload.py b/app/website/common/autoload.py index 36a177e..616a188 100644 --- a/app/website/common/autoload.py +++ b/app/website/common/autoload.py @@ -2,7 +2,7 @@ from app.common import * import copy,hmac db_core=copy.deepcopy(config.database) db_core['type']='mysql' -db_core['host']=['127.0.0.1'] +db_core['host']=['intapp.kwebapp.cn'] db_core['port']=[3306] db_core['user']=['root'] db_core['password']=['intapppasswordtest'] diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 923404f..623242f 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -124,7 +124,7 @@ def modular_list(): break if not nickname: user_info=mysql("user",db_core).field("nickname,img_head").find(k['user_id']) - user_info['img_head']=iconurl.user_info['img_head'] + user_info['img_head']=iconurl+user_info['img_head'] user.append(user_info) else: user_info=nickname @@ -152,16 +152,16 @@ def plug_list(): if modular: where+=" and modular = '"+modular+"'" if group: - list=mysql('plug',db_core_kcweb).order("modular asc,id desc").group('name').page(pagenow,pagesize).where(where).select() + listss=mysql('plug',db_core_kcweb).order("modular asc,id desc").group('name').page(pagenow,pagesize).where(where).select() count=mysql('plug',db_core_kcweb).group('name').where(where).count() else: - list=M('plug',db_core_kcweb).order("modular asc,id desc").page(pagenow,pagesize).where(where).select() + listss=M('plug',db_core_kcweb).order("modular asc,id desc").page(pagenow,pagesize).where(where).select() count=M('plug',db_core_kcweb).where(where).count() iconurl=config.domain['kcwebfile'] lists=[] user=[] index=0 - for k in list: + for k in listss: where="name='"+k['name']+"'" if modular: where+=" and modular = '"+modular+"'" @@ -169,7 +169,7 @@ def plug_list(): edition=[] for k1 in editionlist: edition.append(k1['edition']) - lists[index]=k + lists.append(k) lists[index]['icon']=iconurl+k['icon'] lists[index]['url']='' lists[index]['edition']=edition @@ -193,8 +193,8 @@ def plug_list(): nickname=u break if not nickname: - user_info=mysql("user").field("nickname,img_head").find(k['user_id']) - user_info['img_head']=iconurl.user_info['img_head'] + user_info=mysql("user",db_core).field("nickname,img_head").find(k['user_id']) + user_info['img_head']=iconurl+user_info['img_head'] user.append(user_info) else: user_info=nickname -- Gitee From 4fe2fb92cd8bc596f90e6967ceffdd3d18ca499f Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 22:24:48 +0800 Subject: [PATCH 012/202] kun --- app/website/common/autoload.py | 28 +++- app/website/controller/index/__init__.py | 3 +- .../controller/index/common/__init__.py | 37 +++++- app/website/controller/index/user.py | 125 ++++++++++++++++++ kcweb/common/autoload.py | 20 +-- kcweb/config/__init__.py | 4 +- 6 files changed, 202 insertions(+), 15 deletions(-) create mode 100644 app/website/controller/index/user.py diff --git a/app/website/common/autoload.py b/app/website/common/autoload.py index 616a188..4ba8a54 100644 --- a/app/website/common/autoload.py +++ b/app/website/common/autoload.py @@ -1,5 +1,6 @@ from app.common import * import copy,hmac +import oss2 db_core=copy.deepcopy(config.database) db_core['type']='mysql' db_core['host']=['intapp.kwebapp.cn'] @@ -13,6 +14,7 @@ db_core_ims=copy.deepcopy(db_core) db_core_ims['db']=['core_ims'] db_core_kcweb=copy.deepcopy(db_core) db_core_kcweb['db']=['core_kcweb'] + def isemail(email): ex_email = re.compile(r'^[1-9][0-9]{4,10}@qq\.com') result = ex_email.match(email) @@ -44,4 +46,28 @@ class AlOss2: url=objects else: url=objects - return url \ No newline at end of file + return url + # def uploadFile(filePath,buckets,objects,jurisdiction=False,Location='oss-cn-beijing'): + # # AlOss2.__init() + # # $accessKeyId = self::$accessKeyId; + # # $accessKeySecret = self::$accessKeySecret; + # # $endpoint = "http://{$Location}.aliyuncs.com"; + # # try{ + # # $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); + # # $data=$ossClient->uploadFile($bucket, $object, $filePath); + # # if ($jurisdiction)$ossClient->putObjectAcl($bucket, $object, $jurisdiction);//设置文件为公共读 + # # self::$data['code']=0; + # # self::$data['msg']="成功"; + # # self::$data['data']=$data; + # # return true; + # # } catch(OssException $e) { + # # $msg = $e->getMessage(); + # # self::$data['code']=1; + # # self::$data['msg']=$msg; + # # return false; + # # } + # bucket = oss2.Bucket(auth, 'http://'+Location+'.aliyuncs.com',buckets) + # oss2.resumable_upload(bucket, filePath,objects) + # if jurisdiction: + # bucket.put_object_acl(objects,jurisdiction) + # return True \ No newline at end of file diff --git a/app/website/controller/index/__init__.py b/app/website/controller/index/__init__.py index 4536cad..799bed3 100644 --- a/app/website/controller/index/__init__.py +++ b/app/website/controller/index/__init__.py @@ -1,2 +1,3 @@ from . import index -from . import pub \ No newline at end of file +from . import pub +from . import user \ No newline at end of file diff --git a/app/website/controller/index/common/__init__.py b/app/website/controller/index/common/__init__.py index 42e846d..ecfdffb 100644 --- a/app/website/controller/index/common/__init__.py +++ b/app/website/controller/index/common/__init__.py @@ -1,4 +1,39 @@ # -*- coding: utf-8 -*- from .model import * +def authklogin(username,sign,timestamp): + "授权验证" + if not username or not sign or not timestamp: + return False,"用户名或密码错误",2 + G.user_info=mysql('user',db_core).where("phone='"+username+"' or email='"+username+"'").find() + if not G.user_info: + return False,"用户名或密码错误",2 + if G.user_info['is_frozen']: + return False,"该账号已冻结",6 + mysign=md5(username+timestamp+G.user_info['pwd']) + if times()-int(timestamp)>1296000 or times()-int(timestamp)<-1296000: + return False,"时间戳失效",3 + if sign!=mysign: + return False,"时间戳失效",4 + return True,"登录成功",0 +def check_login(): + account_token=request.args.get('account_token') + if account_token: + G.userinfo=get_cache(account_token) + if not G.userinfo: + return errorjson(code=5,msg='account_token已失效,请重新获取') + elif request.args.get("sign") and request.args.get("timestamp"): + username=request.args.get("username") + sign=request.args.get("sign") + timestamp=request.args.get("timestamp") + status,msg,code=authklogin(username,sign,timestamp) + if not status: + return errorjson(code=code,msg=msg) + elif get_session("login"): + G.user_info=get_session("login") + if not G.user_info: + return "登录失效" + else: + print(request.args.get("timestamp")) + return "登录类型错误" def before_request(): - pass \ No newline at end of file + return check_login() \ No newline at end of file diff --git a/app/website/controller/index/user.py b/app/website/controller/index/user.py new file mode 100644 index 0000000..0aeab21 --- /dev/null +++ b/app/website/controller/index/user.py @@ -0,0 +1,125 @@ +from .common import * +auth = oss2.Auth('LTAISSz1gBwL1oOo', 'MoGi9FusUZx6Vjp8FgLrRkxU22kFON') +def userinfo(): + return successjson(G.user_info) +def uploadmodular(): + "上传模块" + name=request.binary.get("name") + describes=request.binary.get("describes") + try: + title=request.binary.get("title") + except: + title='' + if mysql("modular",db_core_kcweb).where("name='"+name+"' and user_id!="+str(G.user_info['id'])).count(): + return errorjson("该模块已被使用") + objects="kcweb/modular/"+md5("kcwebmodular"+name)+'.zip' + request.binary.save('file',name+".zip") + bucket = oss2.Bucket(auth, 'http://oss-cn-beijing.aliyuncs.com',"fanshufile") + oss2.resumable_upload(bucket, objects,name+".zip") + bucket.put_object_acl(objects,"private") + os.remove(name+".zip") + arr=mysql("modular",db_core_kcweb).where("name='"+name+"' and user_id="+str(G.user_info['id'])).find() + if arr: + update={ + 'id':arr['id'], + 'user_id':G.user_info['id'], + 'name':name, + #'is_examine'=>3, + 'fileurl':objects, + 'updtime':times() + } + if title: + update['title']=title + if describes: + update['describes']=describes + mysql("modular","core_kcweb").where("id",id).update(update) + else: + mysql("modular",db_core_kcweb).insert({ + 'user_id':G.user_info['id'], + "title":title, + 'name':name, + 'describes':describes, + 'fileurl':objects, + 'addtime':times(), + 'updtime':times() + }) + return successjson() + +def uploadplug(): + "上传插件" + name=request.binary.get("name") + describes=request.binary.get("describes") + modular=request.binary.get("modular") + try: + edition=request.binary.get("edition") + except: + edition='' + try: + title=request.binary.get("title") + except: + title='' + try: + token=request.binary.get("token") + except: + token='' + modulart=mysql("modular",db_core_kcweb).field("user_id,is_user_pload_plug").where("name='"+modular+"'").find() + if not modulart: + return errorjson("您不能上传一个插件到不存在的模块中") + if(G.user_info['id']!=modulart['user_id'] and modulart['is_user_pload_plug']!=1): + return errorjson("该模块发布者不允许其他人上传插件") + if(mysql("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id!="+str(G.user_info['id'])).count()): + return errorjson(modular+"模块下,该插件名已被其他用户发布使用,在同一模块下,您不得发布与他人作品相同的插件名") + if(mysql("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])+" and is_examine=3").count()): + return errorjson("您上一个版本的插件待审核,本次发布需等待上一个版本审核通过") + + + if not edition: + arr=M("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])).order("edition desc").find() + if arr: + edition=float(arr['edition'])+0.01 + else: + edition=1 + request.binary.save('file',name+".zip") + edition=str(edition) + objects="kcweb/plug/"+md5("kcwebplug"+name+edition+modular)+'.zip' + bucket = oss2.Bucket(auth, 'http://oss-cn-beijing.aliyuncs.com',"fanshufile") + oss2.resumable_upload(bucket, objects,name+".zip") + bucket.put_object_acl(objects,"private") + os.remove(name+".zip") + t=M("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])).order("id desc").field("title,describes,icon,token").find() + if t: + token=t['token'] + icon='' + if not describes or not title: + if t: + title=t['title'] + describes=t['describes'] + icon=t['icon'] + is_examine=3 + if G.user_info['id']==1: + is_examine=1 + mysql("plug",db_core_kcweb).insert({ + 'user_id':G.user_info['id'], + 'token':token, + 'icon':icon, + "title":title, + 'modular':modular, + "is_examine":is_examine, + 'name':name, + 'edition':edition, + 'describes':describes, + 'fileurl':objects, + 'addtime':times() + }) + if G.user_info['id'] > 1000: + # $send=new \app\common\util\phone\Phone(); + # $send->addressee=config("other.phone"); + # $send->content="【kcweb系统通知】{$this->user_info['nickname']} 在 ".date("Y-m-d H:i:s",time())." 上传一个插件待审核,请管理员及时处理"; + # $send->send() + pass + if mysql("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])).count()>50: + min=mysql("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])).order("id asc").find() + if min: + if bucket.delete_object(min['fileurl']): + mysql("plug",db_core_kcweb).where("id",min['id']).delete() + return successjson(edition) \ No newline at end of file diff --git a/kcweb/common/autoload.py b/kcweb/common/autoload.py index 46460b5..12087f1 100644 --- a/kcweb/common/autoload.py +++ b/kcweb/common/autoload.py @@ -676,10 +676,10 @@ class create: while True: timestamp=times() sign=md5(str(username)+str(timestamp)+md5(md5(password))) - http.set_header['username']=username - http.set_header['timestamp']=str(timestamp) - http.set_header['sign']=sign - http.openurl(config.domain['kcwebapi']+"/user/userinfo") + # http.set_header['username']=username + # http.set_header['timestamp']=str(timestamp) + # http.set_header['sign']=sign + http.openurl(config.domain['kcwebapi']+"/user/userinfo/?username="+username+"×tamp="+str(timestamp)+"&sign="+sign) arr=json_decode(http.get_text) if not arr: os.remove(self.appname+"/"+self.modular+"/controller/"+plug+".zip") @@ -703,7 +703,7 @@ class create: else: os.remove(self.appname+"/"+self.modular+"/controller/"+plug+".zip") return False,arr['msg'] - http.openurl(config.domain['kcwebapi']+"/user/uploadplug/",'POST', + http.openurl(config.domain['kcwebapi']+"/user/uploadplug/?username="+username+"×tamp="+str(timestamp)+"&sign="+sign,'POST', data={'name':str(plug),'describes':'','modular':self.modular}, files={'file':open(self.appname+"/"+self.modular+"/controller/"+plug+".zip", 'rb')}) arr=json_decode(http.get_text) @@ -857,10 +857,10 @@ class create: while True: timestamp=times() sign=md5(str(username)+str(timestamp)+md5(md5(password))) - http.set_header['username']=username - http.set_header['timestamp']=str(timestamp) - http.set_header['sign']=sign - http.openurl(config.domain['kcwebapi']+"/user/uploadmodular/",'POST', + # http.set_header['username']=username + # http.set_header['timestamp']=str(timestamp) + # http.set_header['sign']=sign + http.openurl(config.domain['kcwebapi']+"/user/uploadmodular/?username="+username+"×tamp="+str(timestamp)+"&sign="+sign,'POST', data={'name':str(self.modular),'describes':''}, files={'file':open(self.appname+"/"+self.modular+".zip", 'rb')}) arr=json_decode(http.get_text) @@ -890,7 +890,7 @@ class create: os.remove(self.appname+"/"+self.modular+".zip") return False,arr['msg'] - http.openurl(config.domain['kcwebapi']+"/user/uploadmodular/",'POST', + http.openurl(config.domain['kcwebapi']+"/user/uploadmodular/?username="+username+"×tamp="+str(timestamp)+"&sign="+sign,'POST', data={'name':str(self.modular),'describes':''}, files={'file':open(self.appname+"/"+self.modular+".zip", 'rb')}) arr=json_decode(http.get_text) diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index 00138aa..b946a4d 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -116,8 +116,8 @@ domain={} domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" -domain['kcwebapi']="https://kcweb.kwebapp.cn" -# domain['kcwebapi']="https://intapp.kwebapp.cn/website/index" +# domain['kcwebapi']="https://kcweb.kwebapp.cn" +domain['kcwebapi']="http://127.0.0.1:39001/website/index" #其他配置 other={} -- Gitee From 3e5346a1a54b8e6e7d68dd1ced8b1b8edada4428 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 22:26:38 +0800 Subject: [PATCH 013/202] kun --- app/website/controller/install.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 app/website/controller/install.txt diff --git a/app/website/controller/install.txt b/app/website/controller/install.txt new file mode 100644 index 0000000..bd02041 --- /dev/null +++ b/app/website/controller/install.txt @@ -0,0 +1 @@ +oss2==2.2.0 \ No newline at end of file -- Gitee From a73a81f174dd5f196ea76fd72bca09aebc982b28 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 22:27:28 +0800 Subject: [PATCH 014/202] kun --- kcweb/config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index b946a4d..c646c89 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -117,7 +117,7 @@ domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" # domain['kcwebapi']="https://kcweb.kwebapp.cn" -domain['kcwebapi']="http://127.0.0.1:39001/website/index" +domain['kcwebapi']="http://www.kwebapp.cn" #其他配置 other={} -- Gitee From e92a02e8f7064a155378619645c4d67e078ece9e Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 22:34:41 +0800 Subject: [PATCH 015/202] kun --- app/website/controller/index/user.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/website/controller/index/user.py b/app/website/controller/index/user.py index 0aeab21..8157246 100644 --- a/app/website/controller/index/user.py +++ b/app/website/controller/index/user.py @@ -1,4 +1,5 @@ from .common import * +import oss2 auth = oss2.Auth('LTAISSz1gBwL1oOo', 'MoGi9FusUZx6Vjp8FgLrRkxU22kFON') def userinfo(): return successjson(G.user_info) -- Gitee From 3e7d79e20125fcb90d1b2ecebf34868d602f19c1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 22:36:08 +0800 Subject: [PATCH 016/202] kun --- kcweb/config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index c646c89..62f0f7c 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -116,8 +116,8 @@ domain={} domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" -# domain['kcwebapi']="https://kcweb.kwebapp.cn" -domain['kcwebapi']="http://www.kwebapp.cn" +domain['kcwebapi']="https://kcweb.kwebapp.cn" +# domain['kcwebapi']="http://www.kwebapp.cn" #其他配置 other={} -- Gitee From 1fcd818c9794016633b9a56dd86d5123cc9513c9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 22:40:35 +0800 Subject: [PATCH 017/202] kun --- kcweb/config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index 62f0f7c..c646c89 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -116,8 +116,8 @@ domain={} domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" -domain['kcwebapi']="https://kcweb.kwebapp.cn" -# domain['kcwebapi']="http://www.kwebapp.cn" +# domain['kcwebapi']="https://kcweb.kwebapp.cn" +domain['kcwebapi']="http://www.kwebapp.cn" #其他配置 other={} -- Gitee From 9d6c4c9bbd1d56decfd3b7be94d2e91d7aa79279 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 22:46:21 +0800 Subject: [PATCH 018/202] kun --- app/intapp/controller/index/plug.py | 3 ++- app/website/controller/index/pub.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/intapp/controller/index/plug.py b/app/intapp/controller/index/plug.py index 0ffdfc9..13d924d 100644 --- a/app/intapp/controller/index/plug.py +++ b/app/intapp/controller/index/plug.py @@ -21,9 +21,10 @@ def plug_list(modular="intapp",pagenow=1,group=False): "云插件列表" plug=sqlite('plug',model_app_path).select() http=Http() - http.openurl(config.domain['kcwebapi']+"/pub/plug_list","POST",{ + http.openurl(config.domain['kcwebapi']+"/pub/plug_list","GET",{ "kw":request.args.get("kw"),"modular":modular,"pagenow":pagenow,"group":group }) + print(config.domain['kcwebapi']+"/pub/plug_list") res=json_decode(http.get_text) del http lists=res['data']['lists'] diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 623242f..0c0b015 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -93,7 +93,7 @@ def modular_list(): pagenow=1 where="is_examine=1" if kw: - where+=" and (title LIKE '%{$kw}%' or name LIKE '%"+kw+"%')" + where+=" and (title LIKE '%"+kw+"%' or name LIKE '%"+kw+"%')" user=[] list=mysql('modular',db_core_kcweb).order("id desc").page(pagenow,pagesize).where(where).select() iconurl=config.domain['kcwebfile'] -- Gitee From 9b7679544da727ae8048ccdeb44c176dd5017454 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 22:56:57 +0800 Subject: [PATCH 019/202] kun --- kcweb/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kcweb/app.py b/kcweb/app.py index b4351af..c80d618 100644 --- a/kcweb/app.py +++ b/kcweb/app.py @@ -275,7 +275,7 @@ class web: i+=1 # elif route['plug']: #配置模块但没有匹配插件 # plug=route['plug'] - if getplug: + elif getplug: plug=getplug routedefault,PATH_INFO=web.__getconfigroute( self, @@ -317,6 +317,7 @@ class web: #默认路由end ############################################################ if not modular: modular=route['defmodular'] + return methods,modular,plug,files,funct,tuple(param) def __tran(self,data,status,resheader): "转换控制器返回的内容" -- Gitee From 0a83dfca4857b9a63f4d82c6bafbd4b788870d87 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 22:57:54 +0800 Subject: [PATCH 020/202] kun --- kcweb/config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index c646c89..62f0f7c 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -116,8 +116,8 @@ domain={} domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" -# domain['kcwebapi']="https://kcweb.kwebapp.cn" -domain['kcwebapi']="http://www.kwebapp.cn" +domain['kcwebapi']="https://kcweb.kwebapp.cn" +# domain['kcwebapi']="http://www.kwebapp.cn" #其他配置 other={} -- Gitee From 3ab7226c1e6e67f6c80201fee4dcaada158008fa Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 23:01:35 +0800 Subject: [PATCH 021/202] kun --- app/website/controller/index/pub.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 0c0b015..c515940 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -101,7 +101,7 @@ def modular_list(): index=0 for k in list: lists.append(k) - lists[index]['icon']=iconurl+k['icon'] + lists[index]['icon']=iconurl+"/"+k['icon'] lists[index]['url']='' ation=[] if (k['user_id'] <= 1000): @@ -124,7 +124,7 @@ def modular_list(): break if not nickname: user_info=mysql("user",db_core).field("nickname,img_head").find(k['user_id']) - user_info['img_head']=iconurl+user_info['img_head'] + user_info['img_head']=iconurl+"/"+user_info['img_head'] user.append(user_info) else: user_info=nickname @@ -170,7 +170,7 @@ def plug_list(): for k1 in editionlist: edition.append(k1['edition']) lists.append(k) - lists[index]['icon']=iconurl+k['icon'] + lists[index]['icon']=iconurl+"/"+k['icon'] lists[index]['url']='' lists[index]['edition']=edition ation=[] @@ -194,7 +194,7 @@ def plug_list(): break if not nickname: user_info=mysql("user",db_core).field("nickname,img_head").find(k['user_id']) - user_info['img_head']=iconurl+user_info['img_head'] + user_info['img_head']=iconurl+"/"+user_info['img_head'] user.append(user_info) else: user_info=nickname -- Gitee From bceaf21d09d8135028cece1e3be0f3682d4eb29d Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Aug 2020 23:02:57 +0800 Subject: [PATCH 022/202] kun --- app/intapp/controller/index/plug.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/intapp/controller/index/plug.py b/app/intapp/controller/index/plug.py index 13d924d..6c55a0b 100644 --- a/app/intapp/controller/index/plug.py +++ b/app/intapp/controller/index/plug.py @@ -24,7 +24,6 @@ def plug_list(modular="intapp",pagenow=1,group=False): http.openurl(config.domain['kcwebapi']+"/pub/plug_list","GET",{ "kw":request.args.get("kw"),"modular":modular,"pagenow":pagenow,"group":group }) - print(config.domain['kcwebapi']+"/pub/plug_list") res=json_decode(http.get_text) del http lists=res['data']['lists'] -- Gitee From 8814af3d95d7ab94ee5cfb6b6c1b020ec0c4c904 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 00:27:45 +0800 Subject: [PATCH 023/202] kun --- app/intapp/controller/index/modular.py | 1 - app/intapp/controller/index/plug.py | 10 ++++++---- kcweb/Events.py | 3 ++- kcweb/utill/db/mysql.py | 4 ++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/intapp/controller/index/modular.py b/app/intapp/controller/index/modular.py index 457db3e..b2428d3 100644 --- a/app/intapp/controller/index/modular.py +++ b/app/intapp/controller/index/modular.py @@ -40,7 +40,6 @@ def modular_list(kw='',pagenow=1): http.openurl(config.domain['kcwebapi']+"/pub/modular_list","get",{ "kw":kw,"pagenow":pagenow }) - print(http.get_text) res=json_decode(http.get_text) del http lists=res['data']['lists'] diff --git a/app/intapp/controller/index/plug.py b/app/intapp/controller/index/plug.py index 6c55a0b..e0bc194 100644 --- a/app/intapp/controller/index/plug.py +++ b/app/intapp/controller/index/plug.py @@ -17,13 +17,15 @@ def getpluglist(modular="intapp"): del data[i] i+=1 return successjson(data) -def plug_list(modular="intapp",pagenow=1,group=False): +def plug_list(modular="intapp",pagenow=1,group=''): "云插件列表" + kw=request.args.get("kw") + if not kw: + kw='' plug=sqlite('plug',model_app_path).select() http=Http() - http.openurl(config.domain['kcwebapi']+"/pub/plug_list","GET",{ - "kw":request.args.get("kw"),"modular":modular,"pagenow":pagenow,"group":group - }) + http.openurl(config.domain['kcwebapi']+"/pub/plug_list?modular="+modular+"&pagenow="+pagenow+"&group="+group+"&kw="+kw) + print(http.get_text) res=json_decode(http.get_text) del http lists=res['data']['lists'] diff --git a/kcweb/Events.py b/kcweb/Events.py index 54f63cf..c52d4ef 100644 --- a/kcweb/Events.py +++ b/kcweb/Events.py @@ -14,7 +14,8 @@ class MyFileSystemEventHander(FileSystemEventHandler): if time.time()-eventgtimexz > 3: eventgtimexz=time.time() # print('* 更新文件:%s' % event.src_path) - time.sleep(2) + # time.sleep(2) + time.sleep(0.2) self.restart() class Events: command = ['echo', 'ok'] diff --git a/kcweb/utill/db/mysql.py b/kcweb/utill/db/mysql.py index 52f1f8d..040f693 100644 --- a/kcweb/utill/db/mysql.py +++ b/kcweb/utill/db/mysql.py @@ -761,6 +761,8 @@ class mysql: 参数 length:int 查询数量 """ + offset=int(offset) + length=int(length) self.__limit=[offset,length] return self def page(self,pagenow=1, length = 20): @@ -770,6 +772,8 @@ class mysql: 参数 length:int 查询数量 """ + pagenow=int(pagenow) + length=int(length) offset=(pagenow-1)*length self.__limit=[offset,length] return self -- Gitee From f3c08a7dc8c2271d6bf33480e38239c92092bb9f Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 00:35:44 +0800 Subject: [PATCH 024/202] kun --- app/website/controller/index/pub.py | 3 ++- kcweb/config/__init__.py | 2 +- kcweb/utill/db/mysql.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index c515940..683030a 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -146,6 +146,7 @@ def plug_list(): pagesize=10 if not pagenow: pagenow=1 + print(pagenow,pagesize) where="is_examine=1" if kw: where+=" and (title LIKE '"+kw+"%' or name LIKE '%"+kw+"%')" @@ -193,7 +194,7 @@ def plug_list(): nickname=u break if not nickname: - user_info=mysql("user",db_core).field("nickname,img_head").find(k['user_id']) + user_info=mysql("user",db_core).field("nickname,img_head").where("id",k['user_id']).find() user_info['img_head']=iconurl+"/"+user_info['img_head'] user.append(user_info) else: diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index 62f0f7c..bff952f 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -117,7 +117,7 @@ domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" domain['kcwebapi']="https://kcweb.kwebapp.cn" -# domain['kcwebapi']="http://www.kwebapp.cn" +domain['kcwebapi']="http://www.kwebapp.cn" #其他配置 other={} diff --git a/kcweb/utill/db/mysql.py b/kcweb/utill/db/mysql.py index 040f693..dfe70cf 100644 --- a/kcweb/utill/db/mysql.py +++ b/kcweb/utill/db/mysql.py @@ -762,7 +762,8 @@ class mysql: 参数 length:int 查询数量 """ offset=int(offset) - length=int(length) + if length: + length=int(length) self.__limit=[offset,length] return self def page(self,pagenow=1, length = 20): -- Gitee From a297e79149a3b1d61c7bc2586f66fc3c97d829a7 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 00:56:49 +0800 Subject: [PATCH 025/202] kun --- app/intapp/controller/index/plug.py | 1 - app/website/controller/index/pub.py | 1 - kcweb/utill/db/mysql.py | 12 ++++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/intapp/controller/index/plug.py b/app/intapp/controller/index/plug.py index e0bc194..81977c2 100644 --- a/app/intapp/controller/index/plug.py +++ b/app/intapp/controller/index/plug.py @@ -25,7 +25,6 @@ def plug_list(modular="intapp",pagenow=1,group=''): plug=sqlite('plug',model_app_path).select() http=Http() http.openurl(config.domain['kcwebapi']+"/pub/plug_list?modular="+modular+"&pagenow="+pagenow+"&group="+group+"&kw="+kw) - print(http.get_text) res=json_decode(http.get_text) del http lists=res['data']['lists'] diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 683030a..2035555 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -146,7 +146,6 @@ def plug_list(): pagesize=10 if not pagenow: pagenow=1 - print(pagenow,pagesize) where="is_examine=1" if kw: where+=" and (title LIKE '"+kw+"%' or name LIKE '%"+kw+"%')" diff --git a/kcweb/utill/db/mysql.py b/kcweb/utill/db/mysql.py index dfe70cf..9bf2f81 100644 --- a/kcweb/utill/db/mysql.py +++ b/kcweb/utill/db/mysql.py @@ -966,6 +966,12 @@ class mysql: self.__sql=self.__sql + " WHERE %s" % self.__listTrans() else: print("参数where类型错误") + if self.__group: + s=self.__group + if self.__group1: + for key in self.__group1: + s=s+","+key + self.__sql=self.__sql+" GROUP BY "+s if self.__order: s='' if isinstance(self.__order,list): @@ -999,12 +1005,6 @@ class mysql: else: s=self.__order self.__sql=self.__sql+" ORDER BY "+s - if self.__group: - s=self.__group - if self.__group1: - for key in self.__group1: - s=s+","+key - self.__sql=self.__sql+" GROUP BY "+s if self.__having: self.__sql=self.__sql+" HAVING "+self.__having if self.__limit: -- Gitee From 874cd2bb2233d681ee45f00dd5f3f021f59b7de8 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 01:14:04 +0800 Subject: [PATCH 026/202] kun --- kcweb/utill/db/mysql.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kcweb/utill/db/mysql.py b/kcweb/utill/db/mysql.py index 9bf2f81..9374dca 100644 --- a/kcweb/utill/db/mysql.py +++ b/kcweb/utill/db/mysql.py @@ -550,8 +550,11 @@ class mysql: self.__execute() result = self.__cursor.fetchall() #获取查询结果 self.__cursor.close() - cou=int(result[0][0]) - return cou + if len(result)>1: + return len(result) + else: + cou=int(result[0][0]) + return cou def max(self,field): """查询某字段的最大值 -- Gitee From 062ef76f62f1b536247b85d55d2191d91e33e0c9 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 01:19:14 +0800 Subject: [PATCH 027/202] kun --- app/website/controller/index/pub.py | 1 + kcweb/config/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 2035555..49ceeda 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -212,6 +212,7 @@ def modular(): if data['token']: if data['token']!=token: return errorjson('该模块需要授权码验证',-1) + print(data) url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['filename'],'fanshufile','private') data['dowurl']=url # mysql("modular",db_core_kcweb).where("name='{$name}'").inc('dow_num').update() diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index bff952f..62f0f7c 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -117,7 +117,7 @@ domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" domain['kcwebapi']="https://kcweb.kwebapp.cn" -domain['kcwebapi']="http://www.kwebapp.cn" +# domain['kcwebapi']="http://www.kwebapp.cn" #其他配置 other={} -- Gitee From cf581f6da74f4c3196a81f130c5ef13d1731e579 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 02:33:55 +0800 Subject: [PATCH 028/202] kun --- app/website/common/autoload.py | 42 +++++++---------------------- app/website/controller/index/pub.py | 6 ++--- kcweb/config/__init__.py | 4 +-- 3 files changed, 13 insertions(+), 39 deletions(-) diff --git a/app/website/common/autoload.py b/app/website/common/autoload.py index 4ba8a54..7d58fb7 100644 --- a/app/website/common/autoload.py +++ b/app/website/common/autoload.py @@ -1,6 +1,5 @@ from app.common import * -import copy,hmac -import oss2 +import copy,oss2,base64,hmac,hashlib db_core=copy.deepcopy(config.database) db_core['type']='mysql' db_core['host']=['intapp.kwebapp.cn'] @@ -35,39 +34,16 @@ class AlOss2: AlOss2.accessKeyId = "LTAISSz1gBwL1oOo" AlOss2.accessKeySecret = "MoGi9FusUZx6Vjp8FgLrRkxU22kFON" def Signatureurl(objects,bucket,jurisdiction=''): + "获取oss下载地址" AlOss2.__init() if jurisdiction=='private' or jurisdiction=='bucket': - # ak=AlOss2.accessKeyId - # sk=AlOss2.accessKeySecret - # expire=time()+3600*7 - # StringToSign="GET\n\n\n"+expire+"\n/"+bucket+"/"+objects - # Sign=base64_encode(hash_hmac("sha1",StringToSign,sk,true)) - # url=urlencode(objects)."?OSSAccessKeyId=".$ak."&Expires=".$expire."&Signature=".urlencode($Sign) - url=objects + expire=str(times()+3600*7) + StringToSign="GET\n\n\n"+expire+"\n/"+bucket+"/"+objects + signature = hmac.new(bytes(AlOss2.accessKeySecret,encoding='utf-8'),StringToSign.encode(),hashlib.sha1) + signature = base64.encodestring(signature.digest()) + url=objects+"?OSSAccessKeyId="+AlOss2.accessKeyId+"&Expires="+expire+"&Signature="+signature.decode("utf-8") + url=url[:-1] else: url=objects return url - # def uploadFile(filePath,buckets,objects,jurisdiction=False,Location='oss-cn-beijing'): - # # AlOss2.__init() - # # $accessKeyId = self::$accessKeyId; - # # $accessKeySecret = self::$accessKeySecret; - # # $endpoint = "http://{$Location}.aliyuncs.com"; - # # try{ - # # $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); - # # $data=$ossClient->uploadFile($bucket, $object, $filePath); - # # if ($jurisdiction)$ossClient->putObjectAcl($bucket, $object, $jurisdiction);//设置文件为公共读 - # # self::$data['code']=0; - # # self::$data['msg']="成功"; - # # self::$data['data']=$data; - # # return true; - # # } catch(OssException $e) { - # # $msg = $e->getMessage(); - # # self::$data['code']=1; - # # self::$data['msg']=$msg; - # # return false; - # # } - # bucket = oss2.Bucket(auth, 'http://'+Location+'.aliyuncs.com',buckets) - # oss2.resumable_upload(bucket, filePath,objects) - # if jurisdiction: - # bucket.put_object_acl(objects,jurisdiction) - # return True \ No newline at end of file + \ No newline at end of file diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 49ceeda..2006134 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -212,8 +212,7 @@ def modular(): if data['token']: if data['token']!=token: return errorjson('该模块需要授权码验证',-1) - print(data) - url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['filename'],'fanshufile','private') + url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['fileurl'],'fanshufile','private') data['dowurl']=url # mysql("modular",db_core_kcweb).where("name='{$name}'").inc('dow_num').update() return successjson(data) @@ -232,8 +231,7 @@ def plug(modular,name,edition='',token=''): if data['token']: if data['token']!=token: return errorjson('该插件需要授权码验证',-1) - # $url=config("other.domain.ossfile").\app\common\Oss::Signatureurl($data['fileurl'],'fanshufile','private'); - url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['filename'],'fanshufile','private') + url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['fileurl'],'fanshufile','private') data['dowurl']=url # mysql("plug",db_core_kcweb).where(where).inc('dow_num').update() return successjson(data) diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index 62f0f7c..c646c89 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -116,8 +116,8 @@ domain={} domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" -domain['kcwebapi']="https://kcweb.kwebapp.cn" -# domain['kcwebapi']="http://www.kwebapp.cn" +# domain['kcwebapi']="https://kcweb.kwebapp.cn" +domain['kcwebapi']="http://www.kwebapp.cn" #其他配置 other={} -- Gitee From 8bc0758f4cd748aad6e7ffb22f2f0b2bd0d55c2c Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 02:43:52 +0800 Subject: [PATCH 029/202] kun --- app/website/controller/index/pub.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 2006134..90709a5 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -97,42 +97,38 @@ def modular_list(): user=[] list=mysql('modular',db_core_kcweb).order("id desc").page(pagenow,pagesize).where(where).select() iconurl=config.domain['kcwebfile'] - lists=[] - index=0 - for k in list: - lists.append(k) - lists[index]['icon']=iconurl+"/"+k['icon'] - lists[index]['url']='' + for lists in list: + lists['icon']=iconurl+"/"+lists['icon'] + lists['url']='' ation=[] - if (k['user_id'] <= 1000): + if (lists['user_id'] <= 1000): ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) ation.append({"title":"官方认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfrz.png"}) ation.append({"title":"审核已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsh.png"}) ation.append({"title":"安全认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/anqrz.png"}) - if k['token']: + if lists['token']: ation.append({"title":"该模块已上锁","describe":"","icon":config.domain['kcwebimg']+"/icon/sho1.png"}) - lists[index]['token']=True + lists['token']=True else: - lists[index]['token']=False + lists['token']=False - lists[index]['ation']=ation + lists['ation']=ation nickname="" for u in user: - if u==k['user_id']: + if u==lists['user_id']: nickname=u break if not nickname: - user_info=mysql("user",db_core).field("nickname,img_head").find(k['user_id']) + user_info=mysql("user",db_core).field("nickname,img_head").find(lists['user_id']) user_info['img_head']=iconurl+"/"+user_info['img_head'] user.append(user_info) else: user_info=nickname - lists[index]['user']=user_info - index+=0 + lists['user']=user_info count=mysql('modular',db_core_kcweb).where(where).count() - return successjson(return_list(lists,count,pagenow,pagesize)) + return successjson(return_list(list,count,pagenow,pagesize)) def plug_list(): -- Gitee From 1432f7111e671313712d7a7036dbbbf9aa107936 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 02:45:42 +0800 Subject: [PATCH 030/202] kun --- app/website/controller/index/pub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 90709a5..9faeffb 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -214,7 +214,7 @@ def modular(): return successjson(data) def plug(modular,name,edition='',token=''): - "获取插件" + "获取插件" modular=request.args.get("modular") name=request.args.get("name") edition=request.args.get("edition") -- Gitee From bc0be7a19aa505b257028c7c589d8416502c392e Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 02:49:51 +0800 Subject: [PATCH 031/202] kun --- app/website/controller/index/pub.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py index 9faeffb..3514cc2 100644 --- a/app/website/controller/index/pub.py +++ b/app/website/controller/index/pub.py @@ -213,12 +213,16 @@ def modular(): # mysql("modular",db_core_kcweb).where("name='{$name}'").inc('dow_num').update() return successjson(data) -def plug(modular,name,edition='',token=''): +def plug(): "获取插件" modular=request.args.get("modular") name=request.args.get("name") edition=request.args.get("edition") token=request.args.get("token") + if not edition: + edition='' + if not token: + token='' where="modular ='"+modular+"' and name='"+name+"'" if edition: where+=" and edition='"+edition+"'" -- Gitee From 08c386906a17bc4fae286f72d60ceebd3fb16080 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 02:56:56 +0800 Subject: [PATCH 032/202] kun --- kcweb/common/autoload.py | 4 ++-- kcweb/utill/http.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kcweb/common/autoload.py b/kcweb/common/autoload.py index 12087f1..0a71c0c 100644 --- a/kcweb/common/autoload.py +++ b/kcweb/common/autoload.py @@ -735,7 +735,7 @@ class create: tplug=plug modular=self.modular while True: - http.openurl(config.domain['kcwebapi']+"/pub/plug","POST",data={"modular":modular,"name":str(tplug),"edition":str(edition),"token":token}) + http.openurl(config.domain['kcwebapi']+"/pub/plug","GET",params={"modular":modular,"name":str(tplug),"edition":str(edition),"token":token}) arr=json_decode(http.get_text) if arr: if arr['code']==-1 and cli: @@ -957,7 +957,7 @@ class create: i=0 modular=self.modular while True: - http.openurl(config.domain['kcwebapi']+"/pub/modular","POST",data={"name":modular,"token":token}) + http.openurl(config.domain['kcwebapi']+"/pub/modular","POST",params={"name":modular,"token":token}) arr=json_decode(http.get_text) if arr: if arr['code']==-1 and cli: diff --git a/kcweb/utill/http.py b/kcweb/utill/http.py index 05ffb60..762f237 100644 --- a/kcweb/utill/http.py +++ b/kcweb/utill/http.py @@ -25,7 +25,7 @@ class Http: def gettext(self): """得到响应text""" return self.get_text - def openurl(self,url,method="GET",data=None,files=None,allow_redirects=True): + def openurl(self,url,method="GET",data=None,params=None,files=None,allow_redirects=True): """模拟浏览器请求 url : 目标地址 @@ -48,7 +48,7 @@ class Http: self.req = requests if self.set_cookies and isinstance(self.set_cookies,str): self.cookieserTdict() - response=self.req.request(method, url,data=data,files=files,proxies=self.set_proxies,cookies=self.set_cookies,headers=self.set_header,timeout=self.set_timeout,verify=self.set_verify,allow_redirects=allow_redirects) + response=self.req.request(method, url,data=data,params=params,files=files,proxies=self.set_proxies,cookies=self.set_cookies,headers=self.set_header,timeout=self.set_timeout,verify=self.set_verify,allow_redirects=allow_redirects) response.encoding=self.set_encoding self.get_header=dict(response.headers) cookie=requests.utils.dict_from_cookiejar(response.cookies) -- Gitee From c7635bf706b4c8cb1b7a920ccadc2786b6d4b678 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 03:12:11 +0800 Subject: [PATCH 033/202] kun --- .gitignore | 3 +- app/__init__.py | 2 +- app/website/__init__.py | 1 - app/website/common/__init__.py | 2 - app/website/common/autoload.py | 49 ---- app/website/common/file/sqlite/.gitignore | 1 - app/website/controller/__init__.py | 2 - app/website/controller/index/__init__.py | 3 - .../controller/index/common/__init__.py | 39 --- .../controller/index/common/autoload.py | 1 - .../index/common/file/sqlite/.gitignore | 1 - app/website/controller/index/common/model.py | 4 - app/website/controller/index/index.py | 6 - app/website/controller/index/install.txt | 1 - app/website/controller/index/pub.py | 272 ------------------ app/website/controller/index/user.py | 126 -------- app/website/controller/install.txt | 1 - app/website/install.txt | 1 - 18 files changed, 3 insertions(+), 512 deletions(-) delete mode 100644 app/website/__init__.py delete mode 100644 app/website/common/__init__.py delete mode 100644 app/website/common/autoload.py delete mode 100644 app/website/common/file/sqlite/.gitignore delete mode 100644 app/website/controller/__init__.py delete mode 100644 app/website/controller/index/__init__.py delete mode 100644 app/website/controller/index/common/__init__.py delete mode 100644 app/website/controller/index/common/autoload.py delete mode 100644 app/website/controller/index/common/file/sqlite/.gitignore delete mode 100644 app/website/controller/index/common/model.py delete mode 100644 app/website/controller/index/index.py delete mode 100644 app/website/controller/index/install.txt delete mode 100644 app/website/controller/index/pub.py delete mode 100644 app/website/controller/index/user.py delete mode 100644 app/website/controller/install.txt delete mode 100644 app/website/install.txt diff --git a/.gitignore b/.gitignore index 7ad8b4f..ca4af52 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ __pycache__ /dist /kcweb.egg-info /app/runtime -backup \ No newline at end of file +backup +app/website \ No newline at end of file diff --git a/app/__init__.py b/app/__init__.py index 8d6b335..4be009b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # #导入模块 from . import intapp -from . import website \ No newline at end of file +# from . import website \ No newline at end of file diff --git a/app/website/__init__.py b/app/website/__init__.py deleted file mode 100644 index 72f4562..0000000 --- a/app/website/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import controller \ No newline at end of file diff --git a/app/website/common/__init__.py b/app/website/common/__init__.py deleted file mode 100644 index 6b23e23..0000000 --- a/app/website/common/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from .autoload import * \ No newline at end of file diff --git a/app/website/common/autoload.py b/app/website/common/autoload.py deleted file mode 100644 index 7d58fb7..0000000 --- a/app/website/common/autoload.py +++ /dev/null @@ -1,49 +0,0 @@ -from app.common import * -import copy,oss2,base64,hmac,hashlib -db_core=copy.deepcopy(config.database) -db_core['type']='mysql' -db_core['host']=['intapp.kwebapp.cn'] -db_core['port']=[3306] -db_core['user']=['root'] -db_core['password']=['intapppasswordtest'] -db_core['db']=['core'] -db_core_file=copy.deepcopy(db_core) -db_core_file['db']=['core_file'] -db_core_ims=copy.deepcopy(db_core) -db_core_ims['db']=['core_ims'] -db_core_kcweb=copy.deepcopy(db_core) -db_core_kcweb['db']=['core_kcweb'] - -def isemail(email): - ex_email = re.compile(r'^[1-9][0-9]{4,10}@qq\.com') - result = ex_email.match(email) - if result: - return True - else: - return False -def isphone(phone): - if len(phone)==11: - return True - else: - return False -class AlOss2: - accessKeyId="" - accessKeySecret='' - data=[] - def __init(): - AlOss2.accessKeyId = "LTAISSz1gBwL1oOo" - AlOss2.accessKeySecret = "MoGi9FusUZx6Vjp8FgLrRkxU22kFON" - def Signatureurl(objects,bucket,jurisdiction=''): - "获取oss下载地址" - AlOss2.__init() - if jurisdiction=='private' or jurisdiction=='bucket': - expire=str(times()+3600*7) - StringToSign="GET\n\n\n"+expire+"\n/"+bucket+"/"+objects - signature = hmac.new(bytes(AlOss2.accessKeySecret,encoding='utf-8'),StringToSign.encode(),hashlib.sha1) - signature = base64.encodestring(signature.digest()) - url=objects+"?OSSAccessKeyId="+AlOss2.accessKeyId+"&Expires="+expire+"&Signature="+signature.decode("utf-8") - url=url[:-1] - else: - url=objects - return url - \ No newline at end of file diff --git a/app/website/common/file/sqlite/.gitignore b/app/website/common/file/sqlite/.gitignore deleted file mode 100644 index 0179ab1..0000000 --- a/app/website/common/file/sqlite/.gitignore +++ /dev/null @@ -1 +0,0 @@ -intapp \ No newline at end of file diff --git a/app/website/controller/__init__.py b/app/website/controller/__init__.py deleted file mode 100644 index 6a03892..0000000 --- a/app/website/controller/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ - -from . import index \ No newline at end of file diff --git a/app/website/controller/index/__init__.py b/app/website/controller/index/__init__.py deleted file mode 100644 index 799bed3..0000000 --- a/app/website/controller/index/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from . import index -from . import pub -from . import user \ No newline at end of file diff --git a/app/website/controller/index/common/__init__.py b/app/website/controller/index/common/__init__.py deleted file mode 100644 index ecfdffb..0000000 --- a/app/website/controller/index/common/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -from .model import * -def authklogin(username,sign,timestamp): - "授权验证" - if not username or not sign or not timestamp: - return False,"用户名或密码错误",2 - G.user_info=mysql('user',db_core).where("phone='"+username+"' or email='"+username+"'").find() - if not G.user_info: - return False,"用户名或密码错误",2 - if G.user_info['is_frozen']: - return False,"该账号已冻结",6 - mysign=md5(username+timestamp+G.user_info['pwd']) - if times()-int(timestamp)>1296000 or times()-int(timestamp)<-1296000: - return False,"时间戳失效",3 - if sign!=mysign: - return False,"时间戳失效",4 - return True,"登录成功",0 -def check_login(): - account_token=request.args.get('account_token') - if account_token: - G.userinfo=get_cache(account_token) - if not G.userinfo: - return errorjson(code=5,msg='account_token已失效,请重新获取') - elif request.args.get("sign") and request.args.get("timestamp"): - username=request.args.get("username") - sign=request.args.get("sign") - timestamp=request.args.get("timestamp") - status,msg,code=authklogin(username,sign,timestamp) - if not status: - return errorjson(code=code,msg=msg) - elif get_session("login"): - G.user_info=get_session("login") - if not G.user_info: - return "登录失效" - else: - print(request.args.get("timestamp")) - return "登录类型错误" -def before_request(): - return check_login() \ No newline at end of file diff --git a/app/website/controller/index/common/autoload.py b/app/website/controller/index/common/autoload.py deleted file mode 100644 index a0fd77e..0000000 --- a/app/website/controller/index/common/autoload.py +++ /dev/null @@ -1 +0,0 @@ -from app.website.common import * \ No newline at end of file diff --git a/app/website/controller/index/common/file/sqlite/.gitignore b/app/website/controller/index/common/file/sqlite/.gitignore deleted file mode 100644 index 72a3e83..0000000 --- a/app/website/controller/index/common/file/sqlite/.gitignore +++ /dev/null @@ -1 +0,0 @@ -intappindex \ No newline at end of file diff --git a/app/website/controller/index/common/model.py b/app/website/controller/index/common/model.py deleted file mode 100644 index 2a89589..0000000 --- a/app/website/controller/index/common/model.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -from .autoload import * -# 可以在这里初始化数据库 -model_api_index_path=os.path.split(os.path.realpath(__file__))[0]+"/file/sqlite/intappindex" #数据存放目录 diff --git a/app/website/controller/index/index.py b/app/website/controller/index/index.py deleted file mode 100644 index 0964a08..0000000 --- a/app/website/controller/index/index.py +++ /dev/null @@ -1,6 +0,0 @@ -from .common import * -def index(): - data={ - "name":"kcweb" - } - return successjson(data) diff --git a/app/website/controller/index/install.txt b/app/website/controller/index/install.txt deleted file mode 100644 index fde6665..0000000 --- a/app/website/controller/index/install.txt +++ /dev/null @@ -1 +0,0 @@ -kcweb \ No newline at end of file diff --git a/app/website/controller/index/pub.py b/app/website/controller/index/pub.py deleted file mode 100644 index 3514cc2..0000000 --- a/app/website/controller/index/pub.py +++ /dev/null @@ -1,272 +0,0 @@ -from .common import * -def before_request(): - pass -def sebduser(): - "发送注册验证码" - username=request.args.get("username") - if(mysql("user",db_core).where("phone='"+username+"' or email='"+username+"'").count()): - return errorjson("该账号已注册") - value=get_cache(username+"reg") - ex=86400 - code=randoms(5) - if value: - if len(username)==11 and int(value['sendcount'])>10: - return errorjson("今日验证码发送次数上限,请明日再试") - if len(username)==11 and (times()-int(value['updtime'])<120): - return errorjson("验证码发送频率过高,请稍后再试") - if isemail(username) and (times()-int(value['updtime'])<30): - return errorjson("验证码发送频率过高,请稍后再试") - value={ - 'code':code, - "ex":120, - "sendcount":int(value['sendcount'])+1, - "addtime":value['addtime'], - "updtime":times() - } - ex=ex-(times()-int(value['addtime'])) - if(ex < 10): - ex=86400 - else: - value={ - 'code':code, - "ex":120, - "sendcount":1, - "addtime":times(), - "updtime":times() - } - if len(username)==11: - pass - # $send=new \app\common\util\phone\Phone(); - elif isemail(username): - pass - # $send=new \app\common\util\email\Email(); - # $send->theme="禄可联盟"; - # $send->title="注册验证码"; - else: - return errorjson("请输入正确的手机或邮箱") - # $send->addressee=$username; - # $send->content="【kcweb验证码】您正在注册kcweb一账通账号,本次验证码:{$code}"; - # if($send->send()){ - # set_cache($username."reg", $value,$ex); - # $this->successjson("发送成功"); - # }else{ - # return $this->errorjson("验证码发送失败,请稍后再试"); - # } - -def reg(): - "注册账号" - username=request.args.get("username") - code=request.args.get("code") - password=request.args.get("password") - if mysql("user",db_core).where("phone='"+username+"' or email='"+username+"'").count(): - return errorjson("该账号已注册") - value=get_cache(username+"reg") - if value: - if(times()-int(value['updtime'])<300): - if(code==value['code']): - data={} - if(isphone(username)): - data['phone']=username - else: - data['email']=username - - data['pwd']=md5(md5(password)) - data['nickname']=username - data['addtime']=times() - data['logintime']=times() - mysql("user",db_core).insert(data) - return successjson("注册成功") - else: - return errorjson("验证码错误") - else: - return errorjson("验证码已失效") - else: - return errorjson("验证码错误") -def modular_list(): - "模块列表" - kw=request.args.get("kw") - pagenow=request.args.get("pagenow") - pagesize=request.args.get("pagesize") - if not pagesize: - pagesize=10 - if not pagenow: - pagenow=1 - where="is_examine=1" - if kw: - where+=" and (title LIKE '%"+kw+"%' or name LIKE '%"+kw+"%')" - user=[] - list=mysql('modular',db_core_kcweb).order("id desc").page(pagenow,pagesize).where(where).select() - iconurl=config.domain['kcwebfile'] - for lists in list: - lists['icon']=iconurl+"/"+lists['icon'] - lists['url']='' - ation=[] - if (lists['user_id'] <= 1000): - ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) - ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) - ation.append({"title":"官方认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfrz.png"}) - ation.append({"title":"审核已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsh.png"}) - ation.append({"title":"安全认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/anqrz.png"}) - if lists['token']: - ation.append({"title":"该模块已上锁","describe":"","icon":config.domain['kcwebimg']+"/icon/sho1.png"}) - lists['token']=True - else: - lists['token']=False - - lists['ation']=ation - nickname="" - for u in user: - if u==lists['user_id']: - nickname=u - break - if not nickname: - user_info=mysql("user",db_core).field("nickname,img_head").find(lists['user_id']) - user_info['img_head']=iconurl+"/"+user_info['img_head'] - user.append(user_info) - else: - user_info=nickname - - lists['user']=user_info - count=mysql('modular',db_core_kcweb).where(where).count() - return successjson(return_list(list,count,pagenow,pagesize)) - - -def plug_list(): - "插件列表" - kw=request.args.get("kw") - modular=request.args.get("modular") - pagenow=request.args.get("pagenow") - pagesize=request.args.get("pagesize") - group=request.args.get("group") - if not pagesize: - pagesize=10 - if not pagenow: - pagenow=1 - where="is_examine=1" - if kw: - where+=" and (title LIKE '"+kw+"%' or name LIKE '%"+kw+"%')" - if modular: - where+=" and modular = '"+modular+"'" - if group: - listss=mysql('plug',db_core_kcweb).order("modular asc,id desc").group('name').page(pagenow,pagesize).where(where).select() - count=mysql('plug',db_core_kcweb).group('name').where(where).count() - else: - listss=M('plug',db_core_kcweb).order("modular asc,id desc").page(pagenow,pagesize).where(where).select() - count=M('plug',db_core_kcweb).where(where).count() - iconurl=config.domain['kcwebfile'] - lists=[] - user=[] - index=0 - for k in listss: - where="name='"+k['name']+"'" - if modular: - where+=" and modular = '"+modular+"'" - editionlist=mysql('plug',db_core_kcweb).order("edition desc").where(where).field("edition").limit(100).select() - edition=[] - for k1 in editionlist: - edition.append(k1['edition']) - lists.append(k) - lists[index]['icon']=iconurl+"/"+k['icon'] - lists[index]['url']='' - lists[index]['edition']=edition - ation=[] - if (k['user_id'] <= 1000): - ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) - ation.append({"title":"官方发布","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsq.png"}) - ation.append({"title":"官方认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfrz.png"}) - ation.append({"title":"审核已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/guanfsh.png"}) - ation.append({"title":"安全认证已通过","describe":"","icon":config.domain['kcwebimg']+"/icon/anqrz.png"}) - if k['token']: - ation.append({"title":"该模块已上锁","describe":"","icon":config.domain['kcwebimg']+"/icon/sho1.png"}) - lists[index]['token']=True - else: - lists[index]['token']=False - lists[index]['ation']=ation - nickname="" - for u in user: - if u==k['user_id']: - user.append(u) - nickname=u - break - if not nickname: - user_info=mysql("user",db_core).field("nickname,img_head").where("id",k['user_id']).find() - user_info['img_head']=iconurl+"/"+user_info['img_head'] - user.append(user_info) - else: - user_info=nickname - lists[index]['user']=user_info - index+=1 - return successjson(return_list(lists,count,pagenow,pagesize)) - - -def modular(): - "获取模块" - name=request.args.get("name") - token=request.args.get("token") - data=mysql("modular",db_core_kcweb).where("name='"+name+"'").find() - if data: - if data['token']: - if data['token']!=token: - return errorjson('该模块需要授权码验证',-1) - url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['fileurl'],'fanshufile','private') - data['dowurl']=url - # mysql("modular",db_core_kcweb).where("name='{$name}'").inc('dow_num').update() - return successjson(data) - -def plug(): - "获取插件" - modular=request.args.get("modular") - name=request.args.get("name") - edition=request.args.get("edition") - token=request.args.get("token") - if not edition: - edition='' - if not token: - token='' - where="modular ='"+modular+"' and name='"+name+"'" - if edition: - where+=" and edition='"+edition+"'" - data=mysql("plug",db_core_kcweb).where(where).order("addtime desc").find() - if data: - if data['token']: - if data['token']!=token: - return errorjson('该插件需要授权码验证',-1) - url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['fileurl'],'fanshufile','private') - data['dowurl']=url - # mysql("plug",db_core_kcweb).where(where).inc('dow_num').update() - return successjson(data) - -def soft_list(): - "软件列表" - where="" - kw=request.args.get("kw") - pagenow=request.args.get("pagenow") - pagesize=request.args.get("pagesize") - if not pagesize: - pagesize=10 - if not pagenow: - pagenow=1 - if kw: - where="title LIKE '"+kw+"'" - list=mysql('soft',db_core_kcweb).field("id,icon,title,edition,shell,describes,paths,filename,platform,updtime").order("id desc").page(pagenow,pagesize).where(where).select() - domain=config.domain['kcwebfile'] - lists=[] - i=0 - for k in list: - lists[i]=k - lists[i]['icon']=domain+"/"+k['icon'] - i+=1 - count=M('soft',db_core_kcweb).where(where).count() - return successjson(return_list(lists,count,pagenow,pagesize)) - -def soft_dow_url(): - "获取软件下载地址" - id=request.args.get("id") - data=mysql('soft',db_core_kcweb).where("id",id).find() - if data: - url=config.domain['kcwebfile']+"/"+AlOss2.Signatureurl(data['filename'],'fanshufile','private') - data['dowurl']=url - # mysql('soft',db_core_kcweb).where("id",id).inc('dow_num').update() - return successjson(data) - else: - return errorjson("参数错误") diff --git a/app/website/controller/index/user.py b/app/website/controller/index/user.py deleted file mode 100644 index 8157246..0000000 --- a/app/website/controller/index/user.py +++ /dev/null @@ -1,126 +0,0 @@ -from .common import * -import oss2 -auth = oss2.Auth('LTAISSz1gBwL1oOo', 'MoGi9FusUZx6Vjp8FgLrRkxU22kFON') -def userinfo(): - return successjson(G.user_info) -def uploadmodular(): - "上传模块" - name=request.binary.get("name") - describes=request.binary.get("describes") - try: - title=request.binary.get("title") - except: - title='' - if mysql("modular",db_core_kcweb).where("name='"+name+"' and user_id!="+str(G.user_info['id'])).count(): - return errorjson("该模块已被使用") - objects="kcweb/modular/"+md5("kcwebmodular"+name)+'.zip' - request.binary.save('file',name+".zip") - bucket = oss2.Bucket(auth, 'http://oss-cn-beijing.aliyuncs.com',"fanshufile") - oss2.resumable_upload(bucket, objects,name+".zip") - bucket.put_object_acl(objects,"private") - os.remove(name+".zip") - arr=mysql("modular",db_core_kcweb).where("name='"+name+"' and user_id="+str(G.user_info['id'])).find() - if arr: - update={ - 'id':arr['id'], - 'user_id':G.user_info['id'], - 'name':name, - #'is_examine'=>3, - 'fileurl':objects, - 'updtime':times() - } - if title: - update['title']=title - if describes: - update['describes']=describes - mysql("modular","core_kcweb").where("id",id).update(update) - else: - mysql("modular",db_core_kcweb).insert({ - 'user_id':G.user_info['id'], - "title":title, - 'name':name, - 'describes':describes, - 'fileurl':objects, - 'addtime':times(), - 'updtime':times() - }) - return successjson() - -def uploadplug(): - "上传插件" - name=request.binary.get("name") - describes=request.binary.get("describes") - modular=request.binary.get("modular") - try: - edition=request.binary.get("edition") - except: - edition='' - try: - title=request.binary.get("title") - except: - title='' - try: - token=request.binary.get("token") - except: - token='' - modulart=mysql("modular",db_core_kcweb).field("user_id,is_user_pload_plug").where("name='"+modular+"'").find() - if not modulart: - return errorjson("您不能上传一个插件到不存在的模块中") - if(G.user_info['id']!=modulart['user_id'] and modulart['is_user_pload_plug']!=1): - return errorjson("该模块发布者不允许其他人上传插件") - if(mysql("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id!="+str(G.user_info['id'])).count()): - return errorjson(modular+"模块下,该插件名已被其他用户发布使用,在同一模块下,您不得发布与他人作品相同的插件名") - if(mysql("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])+" and is_examine=3").count()): - return errorjson("您上一个版本的插件待审核,本次发布需等待上一个版本审核通过") - - - if not edition: - arr=M("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])).order("edition desc").find() - if arr: - edition=float(arr['edition'])+0.01 - else: - edition=1 - request.binary.save('file',name+".zip") - edition=str(edition) - objects="kcweb/plug/"+md5("kcwebplug"+name+edition+modular)+'.zip' - bucket = oss2.Bucket(auth, 'http://oss-cn-beijing.aliyuncs.com',"fanshufile") - oss2.resumable_upload(bucket, objects,name+".zip") - bucket.put_object_acl(objects,"private") - os.remove(name+".zip") - t=M("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])).order("id desc").field("title,describes,icon,token").find() - if t: - token=t['token'] - icon='' - if not describes or not title: - if t: - title=t['title'] - describes=t['describes'] - icon=t['icon'] - is_examine=3 - if G.user_info['id']==1: - is_examine=1 - mysql("plug",db_core_kcweb).insert({ - 'user_id':G.user_info['id'], - 'token':token, - 'icon':icon, - "title":title, - 'modular':modular, - "is_examine":is_examine, - 'name':name, - 'edition':edition, - 'describes':describes, - 'fileurl':objects, - 'addtime':times() - }) - if G.user_info['id'] > 1000: - # $send=new \app\common\util\phone\Phone(); - # $send->addressee=config("other.phone"); - # $send->content="【kcweb系统通知】{$this->user_info['nickname']} 在 ".date("Y-m-d H:i:s",time())." 上传一个插件待审核,请管理员及时处理"; - # $send->send() - pass - if mysql("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])).count()>50: - min=mysql("plug",db_core_kcweb).where("name='"+name+"' and modular='"+modular+"' and user_id="+str(G.user_info['id'])).order("id asc").find() - if min: - if bucket.delete_object(min['fileurl']): - mysql("plug",db_core_kcweb).where("id",min['id']).delete() - return successjson(edition) \ No newline at end of file diff --git a/app/website/controller/install.txt b/app/website/controller/install.txt deleted file mode 100644 index bd02041..0000000 --- a/app/website/controller/install.txt +++ /dev/null @@ -1 +0,0 @@ -oss2==2.2.0 \ No newline at end of file diff --git a/app/website/install.txt b/app/website/install.txt deleted file mode 100644 index fde6665..0000000 --- a/app/website/install.txt +++ /dev/null @@ -1 +0,0 @@ -kcweb \ No newline at end of file -- Gitee From 8da83ccf8632ebafc00cab3f144a3a53fcce72a9 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 03:12:25 +0800 Subject: [PATCH 034/202] kun --- app/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 4be009b..ed8d0eb 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,4 +1,3 @@ # -*- coding: utf-8 -*- # #导入模块 -from . import intapp -# from . import website \ No newline at end of file +from . import intapp \ No newline at end of file -- Gitee From 2502d23b533d9c0a8b220a76c2fca7cb26d63e57 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 03:19:55 +0800 Subject: [PATCH 035/202] kun --- kcweb/config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index c646c89..62f0f7c 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -116,8 +116,8 @@ domain={} domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" -# domain['kcwebapi']="https://kcweb.kwebapp.cn" -domain['kcwebapi']="http://www.kwebapp.cn" +domain['kcwebapi']="https://kcweb.kwebapp.cn" +# domain['kcwebapi']="http://www.kwebapp.cn" #其他配置 other={} -- Gitee From cdd699914d96c60420246eb87d91bfa5f1d5d8d4 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 03:56:07 +0800 Subject: [PATCH 036/202] kun --- kcweb/config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py index 62f0f7c..c646c89 100644 --- a/kcweb/config/__init__.py +++ b/kcweb/config/__init__.py @@ -116,8 +116,8 @@ domain={} domain['kcwebfile']="https://file.kwebapp.cn" domain['kcwebstatic']="https://static.kwebapp.cn" domain['kcwebimg']="https://img.kwebapp.cn" -domain['kcwebapi']="https://kcweb.kwebapp.cn" -# domain['kcwebapi']="http://www.kwebapp.cn" +# domain['kcwebapi']="https://kcweb.kwebapp.cn" +domain['kcwebapi']="http://www.kwebapp.cn" #其他配置 other={} -- Gitee From 8f2e090a63cb8010490625be6eff91b839cdb270 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 04:11:27 +0800 Subject: [PATCH 037/202] kun --- app/common/__init__.py | 11 +- app/intapp/controller/__init__.py | 3 +- app/intapp/controller/soft/__init__.py | 8 + app/intapp/controller/soft/common/SOFT.py | 213 ++++++++ app/intapp/controller/soft/common/__init__.py | 2 + app/intapp/controller/soft/common/autoload.py | 10 + .../soft/common/file/sqlite/.gitignore | 1 + .../soft/common/file/sqlite/php_exten | Bin 0 -> 24576 bytes app/intapp/controller/soft/common/model.py | 85 +++ app/intapp/controller/soft/frp.py | 133 +++++ app/intapp/controller/soft/index.py | 91 ++++ app/intapp/controller/soft/install.txt | 1 + app/intapp/controller/soft/mongodb.py | 247 +++++++++ app/intapp/controller/soft/mysql.py | 254 +++++++++ app/intapp/controller/soft/nginx.py | 360 ++++++++++++ app/intapp/controller/soft/page.py | 13 + app/intapp/controller/soft/php.py | 266 +++++++++ app/intapp/controller/soft/redis.py | 69 +++ app/intapp/controller/soft/role.txt | 44 ++ .../controller/soft/tpl/index/home.html | 428 +++++++++++++++ app/intapp/controller/soft/tpl/index/web.html | 515 ++++++++++++++++++ app/intapp/controller/soft/tpl/soft/frp.html | 250 +++++++++ app/intapp/controller/soft/tpl/soft/git.html | 69 +++ .../controller/soft/tpl/soft/kodexplorer.html | 88 +++ .../controller/soft/tpl/soft/mongodb.html | 436 +++++++++++++++ .../controller/soft/tpl/soft/mysql.html | 106 ++++ .../controller/soft/tpl/soft/nginx.html | 113 ++++ app/intapp/controller/soft/tpl/soft/php.html | 331 +++++++++++ .../controller/soft/tpl/soft/phpmyadmin.html | 90 +++ .../controller/soft/tpl/soft/redis.html | 127 +++++ 30 files changed, 4358 insertions(+), 6 deletions(-) create mode 100644 app/intapp/controller/soft/__init__.py create mode 100644 app/intapp/controller/soft/common/SOFT.py create mode 100644 app/intapp/controller/soft/common/__init__.py create mode 100644 app/intapp/controller/soft/common/autoload.py create mode 100644 app/intapp/controller/soft/common/file/sqlite/.gitignore create mode 100644 app/intapp/controller/soft/common/file/sqlite/php_exten create mode 100644 app/intapp/controller/soft/common/model.py create mode 100644 app/intapp/controller/soft/frp.py create mode 100644 app/intapp/controller/soft/index.py create mode 100644 app/intapp/controller/soft/install.txt create mode 100644 app/intapp/controller/soft/mongodb.py create mode 100644 app/intapp/controller/soft/mysql.py create mode 100644 app/intapp/controller/soft/nginx.py create mode 100644 app/intapp/controller/soft/page.py create mode 100644 app/intapp/controller/soft/php.py create mode 100644 app/intapp/controller/soft/redis.py create mode 100644 app/intapp/controller/soft/role.txt create mode 100644 app/intapp/controller/soft/tpl/index/home.html create mode 100644 app/intapp/controller/soft/tpl/index/web.html create mode 100644 app/intapp/controller/soft/tpl/soft/frp.html create mode 100644 app/intapp/controller/soft/tpl/soft/git.html create mode 100644 app/intapp/controller/soft/tpl/soft/kodexplorer.html create mode 100644 app/intapp/controller/soft/tpl/soft/mongodb.html create mode 100644 app/intapp/controller/soft/tpl/soft/mysql.html create mode 100644 app/intapp/controller/soft/tpl/soft/nginx.html create mode 100644 app/intapp/controller/soft/tpl/soft/php.html create mode 100644 app/intapp/controller/soft/tpl/soft/phpmyadmin.html create mode 100644 app/intapp/controller/soft/tpl/soft/redis.html diff --git a/app/common/__init__.py b/app/common/__init__.py index 2629661..adf8e5e 100644 --- a/app/common/__init__.py +++ b/app/common/__init__.py @@ -215,11 +215,12 @@ def file_get_content(filename,encoding=False): encoding 是否返回文件编码 默认否 """ fileData='' - with open(filename, 'rb') as f: - cur_encoding = chardet.detect(f.read())['encoding'] - #用获取的编码读取该文件而不是python3默认的utf-8读取。 - with open(filename,encoding=cur_encoding) as file: - fileData = file.read() + if os.path.isfile(filename): + with open(filename, 'rb') as f: + cur_encoding = chardet.detect(f.read())['encoding'] + #用获取的编码读取该文件而不是python3默认的utf-8读取。 + with open(filename,encoding=cur_encoding) as file: + fileData = file.read() if encoding: return fileData,cur_encoding else: diff --git a/app/intapp/controller/__init__.py b/app/intapp/controller/__init__.py index 6a03892..f4dbb41 100644 --- a/app/intapp/controller/__init__.py +++ b/app/intapp/controller/__init__.py @@ -1,2 +1,3 @@ -from . import index \ No newline at end of file +from . import index +from . import soft \ No newline at end of file diff --git a/app/intapp/controller/soft/__init__.py b/app/intapp/controller/soft/__init__.py new file mode 100644 index 0000000..f7a8da3 --- /dev/null +++ b/app/intapp/controller/soft/__init__.py @@ -0,0 +1,8 @@ +from . import index +from . import page +from . import nginx +from . import mysql +from . import redis +from . import mongodb +from . import frp +from . import php \ No newline at end of file diff --git a/app/intapp/controller/soft/common/SOFT.py b/app/intapp/controller/soft/common/SOFT.py new file mode 100644 index 0000000..1ac9add --- /dev/null +++ b/app/intapp/controller/soft/common/SOFT.py @@ -0,0 +1,213 @@ +# -*- coding: utf-8 -*- +from .model import * +class SOFT: + def softlist(kw,pagenow,pagesize): + "软件列表" + if config.app['appmode']=='develop': + where="1=1" + else: + where="platform='"+get_sysinfo()['uname'][0]+"'" + if kw: + where+=" and title LIKE '%"+kw+"%' or describes LIKE '%"+kw+"%'" + lists=sqlite("soft",model_intapp_soft_path).where(where).page(pagenow,pagesize).select() + if len(lists) < 1: + SOFT.updatesoftlist() + lists=sqlite("soft",model_intapp_soft_path).where(where).page(pagenow,pagesize).select() + if 'Linux' in get_sysinfo()['platform']: + i=0 + for k in lists: + if k['status'] == 0 and k['platform']=='Linux': #检查软件是否已经安装 + if (os.path.exists(k['paths']+k['title']+k['edition'])) : + lists[i]['status']=4 + sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':lists[i]['status']}) + if (k['status'] == 10 or k['status'] == 4) and k['platform']=='Linux': #检查软件是否在运行中 + if 'nginx' in k['title'] : + if not get_process_id('nginx'): + if k['status'] == 10: + lists[i]['status']=4 + sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止 + else: + if k['status'] == 4: + lists[i]['status']=10 + sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中 + elif 'redis' in k['title']: + if not get_process_id('redis'): + if k['status'] == 10: + lists[i]['status']=4 + sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止 + else: + if k['status'] == 4: + lists[i]['status']=10 + sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中 + elif 'mysql' in k['title']: + if not get_process_id('mysql'): + if k['status'] == 10: + lists[i]['status']=4 + sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止 + else: + if k['status'] == 4: + lists[i]['status']=10 + sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中 + elif 'php5' in k['title']+k['edition'] or 'php7' in k['title']+k['edition']: + title=k['title']+k['edition'] + # print("php",title,title.replace(".", "")+"-fpm") + if not get_process_id(title): + if k['status'] == 10: + lists[i]['status']=4 + sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止 + else: + if k['status'] == 4: + lists[i]['status']=10 + sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中 + i+=1 + count=sqlite("soft",model_intapp_soft_path).where(where).count() + data=return_list(lists,count,pagenow,pagesize) + return data + def updatesoftlist(): + "更新软件列表" + http=Http() + sqlite("soft",model_intapp_soft_path).where("1=1").delete() + def openkcweb(pagenow=1,pagesize=20): + http.openurl(config.domain['kcwebapi']+"/pub/soft_list","POST",{ + "pagenow":pagenow,"pagesize":pagesize + }) + res=json_decode(http.get_text) + lists=[] + if res['code']==0: + for k in res['data']['lists']: + k['status']=0 + k['msg']='' + k['addtime']=times() + lists.append(k) + sqlite("soft",model_intapp_soft_path).insert(lists) + if pagenow log 2>&1 &",name="redis服务") + return True + elif 'mysql' == arr['title']: + if os.path.isfile(arr['paths']+arr['title']+arr['edition']+"/support-files/mysql.server"): + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":"安装成功"}) + system_start.insert_Boot_up("mysqld start",name="mysql服务") + return True + elif 'frp' == arr['title']: + if os.path.isfile(arr['paths']+arr['title']+arr['edition']+"/frps") and os.path.isfile(arr['paths']+arr['title']+arr['edition']+"/frpc"): + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":"安装成功"}) + return True + else: + if os.path.exists(arr['paths']+arr['title']+arr['edition']): + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":"安装成功"}) + return True + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"安装失败,目录不存在"+arr['paths']+arr['title']+arr['edition']}) + else: + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"安装失败"}) + else: + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"下载失败"}) + except Exception as e: + sqlite('soft',model_intapp_soft_path).where('id',id).update({'status':0,'msg':'安装失败'+str(e)}) + def start(id): + "启动软件服务" + arr=sqlite("soft",model_intapp_soft_path).where("id",id).find() + if arr['platform']=='Linux': ###############################LINUX + if 'nginx' == arr['title']: + os.system("nginx") + elif 'php' == arr['title']: + titleedition=arr['title']+arr['edition'] + fpmname=titleedition.replace(".", "")+"-fpm" + os.system(fpmname+" -c "+arr['paths']+arr['title']+arr['edition']+"/bin/php.ini -R") + # print("php启动",fpmname+" -c "+arr['paths']+arr['title']+arr['edition']+"/bin/php.ini -R") + elif 'redis' == arr['title']: + os.system("nohup redis-server "+arr['paths']+arr['title']+arr['edition']+"/redis.conf > log 2>&1 &") + elif 'mysql' == arr['title']: + os.system("mysqld start") + else: + os.system("cd "+arr['paths']+arr['title']+arr['edition']+" && bash start.sh") + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":10,"msg":"运行中"}) + else: + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":""}) + def stop(id): + arr=sqlite("soft",model_intapp_soft_path).where("id",id).find() + if arr['platform']=='Linux': ###############################LINUX + if 'nginx' == arr['title']: + os.system("pkill nginx") + elif 'php' == arr['title']: + titleedition=arr['title']+arr['edition'] + fpmname=titleedition.replace(".", "")+"-fpm" + os.system("pkill -9 "+fpmname) + elif 'redis' == arr['title']: + os.system("pkill redis") + elif 'mysql' == arr['title']: + os.system("mysqld stop") + elif 'mongo' == arr['title']: + os.system("pkill mongo") + else: + os.system("cd "+arr['paths']+arr['title']+arr['edition']+" && bash stop.sh") + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":""}) + def uninstall(id): + try: + arr=sqlite("soft",model_intapp_soft_path).where("id",id).find() + if arr['platform']=='Linux': ###############################LINUX + os.system("rm -rf "+arr['paths']+arr['title']+arr['edition']) + startpath="/usr/bin/" + if 'nginx' == arr['title']: + system_start.del_Boot_up("nginx") + os.system("pkill -9 nginx") + model_intapp_menu.delete(title="网站管理",sort=9000) + os.system("rm -rf "+startpath+"nginx") + elif 'redis' == arr['title']: + system_start.del_Boot_up("nohup redis-server "+arr['paths']+arr['title']+arr['edition']+"/redis.conf > log 2>&1 &") + os.system("rm -rf "+startpath+"redis-server") + elif 'php' == arr['title']: + titleedition=arr['title']+arr['edition'] + fpmname=titleedition.replace(".", "")+"-fpm" + system_start.del_Boot_up(fpmname+" -c "+arr['paths']+arr['title']+arr['edition']+"/bin/php.ini -R") + + + os.system("rm -rf "+startpath+fpmname) + elif 'mysql' == arr['title']: + system_start.del_Boot_up("mysqld start") + os.system("rm -rf "+startpath+"mysqld && rm -rf "+startpath+"mysql && rm -rf /etc/my.cnf") + elif 'mongodb' == arr['title']: + system_start.del_Boot_up("mongo",True) + os.system("pkill -9 mongo") + os.system("rm -rf /data/mongodb") + elif 'frp' == arr['title']: + system_start.del_Boot_up("frps",True) + system_start.del_Boot_up("frpc",True) + os.system("pkill -9 frps") + os.system("pkill -9 frpc") + else: + if os.path.exists(arr['paths']+arr['title']+arr['edition']): + sqlite('soft',model_intapp_soft_path).where('id',id).update({'status':4,'msg':'卸载失败'}) + return + except Exception as e: + sqlite('soft',model_intapp_soft_path).where('id',id).update({'status':4,'msg':'卸载失败'+str(e)}) + else: + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"已卸载"}) \ No newline at end of file diff --git a/app/intapp/controller/soft/common/__init__.py b/app/intapp/controller/soft/common/__init__.py new file mode 100644 index 0000000..8879824 --- /dev/null +++ b/app/intapp/controller/soft/common/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from .SOFT import * \ No newline at end of file diff --git a/app/intapp/controller/soft/common/autoload.py b/app/intapp/controller/soft/common/autoload.py new file mode 100644 index 0000000..c4bee80 --- /dev/null +++ b/app/intapp/controller/soft/common/autoload.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +from app.intapp.common import * +import subprocess +def get_process_id(name): + try: + child = subprocess.Popen(['pgrep', '-f', name],stdout=subprocess.PIPE, shell=False) + response = child.communicate()[0] + return [int(pid) for pid in response.split()] + except: + return [] diff --git a/app/intapp/controller/soft/common/file/sqlite/.gitignore b/app/intapp/controller/soft/common/file/sqlite/.gitignore new file mode 100644 index 0000000..f3c316e --- /dev/null +++ b/app/intapp/controller/soft/common/file/sqlite/.gitignore @@ -0,0 +1 @@ +soft \ No newline at end of file diff --git a/app/intapp/controller/soft/common/file/sqlite/php_exten b/app/intapp/controller/soft/common/file/sqlite/php_exten new file mode 100644 index 0000000000000000000000000000000000000000..643a9415b601d5c3a803687d93aa38c01a1857ef GIT binary patch literal 24576 zcmeHPdu&tJ8TXAH=i0t@n$eJTAnll zT)4ND$tfr6>l^LFH}ea;&HVa?CfizDBj2#0iEr3kSI2K` zTwh<)xP^b#wuP_R+_YhR0~}p%YiKIv1LN#p%7?rmpNoI4rg6=>n#Khcl~oJ*THDh# zo9mkR`SauLmh#Q6ptH@p%@vIATe)=E1p5X9&)9;+v{^-$CGHICAdAlS4DZ{ zk_n(3&CMY%G?*wvDc>F#|33?}Vbo>ieu-mGpZl-eFU@`C2JR@AWAYep84C?>81mTt z?4vpF<<#o`oc&35t!}UOu0Eh$nl+GB!klBQn%`=+j5~1Myh+2%Dq)G)tkW5rw>dVh z+bCQ;6FJ=TR&= z^0EpZnzP4-K1B-@15Od(6d;b%0h%^D+A;~IvzGqz>i=K1%+Fg-T zy^&*Ag@Kdz(;Bo~BsQuR`x_f2wSh|*jc{{-&m)9kcO#$R4!_^$5{C9hdb&T|Lxlbt zu{V#xo7-2;ME1NBdwDoI{7Q82{OvtwN5gLlL#HAqyZFko%Chq4p@Wh0@A2ag0I5|q zqp>YyL7#QPr$Ux;*d-+uSHaQO20fY@RAU^QyO z<~a0jfZk13{D1>&Qq7Wl05|vpPKVRug09BG2ZY}JJd6lFw(l%-^Y&Z&qC=-+*It3s zBlNr$JG?jg27!|&?7b`;>=in%j}BasPiJ3G5NCGWDR}`JyWnOc=sA#;nLaYKsb8&2y`VDJ_m0iUGE47Z`|*aO;TZz zfIT)CLnGRJIN^C-mY8s?Zf}k=laPQPjBer5zUYbl!nqM)_$?fG;v5YVNP1&$dowV& zg$6!?#cA5}2$0E#={gt5INRICgvvn2u{}5=OVB*C)JU$KUUx#r(;5TV9`tJf&HX(< zQe2%Oqpq%8a&?361J3(_Jit+0ok4L+ne3I)CZJtHb3df+Sw>x5IWM}p!IOY`VVb-g(y^m;n1PMrvq2Nf0X#%9vzAe!WJ`o6Nq`o3~!1Cru%*bMp{1QKtr`aT1k&jLEY zQG5=o_=kiulGgcG+61(Z(cD^f&obz9#1n?MSA8F#bz}jKGPAOiKeGZnz+OiqECbkz zyJM%^-7ST0W7$u@FWqd+%`>@oHSj}UQ~|00Re&l$6`%@G1*ig40jdC1fGR*0pbGrI zC}3u^#S8?+rMij+v)-e5So<}j>$m*V@~VYb=l``|r;-2Hdvu@215`BspKN6V&HrOn zfjSdU^Z%*G`Ind7lmFLym`xD(#QZ;5At!hkv5aA|6Fj=K!o=}11}Vd%pY|B47|uNb z;oK86|37}6RyjYG|2GzD+Gzg&flJ+J{y*tbw+UuRn*WD_NE~;`R=LIV|GDj&!Efoe zUYh^Ee+@0BLTUa#y-Gkaoh;WX()@pFwcM!TcQF4Cv+9uE(bGBbvYQ)iI;3;` zT;5?)>a7y$k1|^kmL7S9qCGb9A2iPrahOX5&!$Y4gyFD~O2S4WfE00C0ZAzdGi9(O z41vUwun{QG8u>U-2{=kgm`Rzw6HZCW_xj?sE3e`Kw2#o-73!X4up|t@#E9F-hk)}T zF_Z&Pfu9jq+?Z0U%bH;LBzYeKv%^Rq8sQcL7o`r_G);BLNat;|U1h+g&?Zk;NmR?- zM}{Pq+aR_Rja1EtS)h=}g~-O4T8NA*)8b*O;Z63~@FveZkWDEFHIC!t(zs44WFI$N z3rMi8=W#qk^12>lYCbM4HgOj>TmghC$eg*7i<4JqWyHm$MNsx|!^J?am}q|ldMV3d zj1TJJ(jtNmZrF@QsvnaaoVX!7;wW}FlyK2rcYG!3WugSGp{$P31+-qLP-QpfLbs6s% z?S{V_Rd`+0p?_V4uPQ@quuhfxKn0#t$Tjsh*u;LR8WH}T;VCV#-y8Vvd% z1fYHb%6;yT>G>GP|N4R47`2&e?U}>TrsA=7v+2jD=HfLL}&>ldx++Hf7aWFnlcnf=O9|gkAaQiQMsw`s0h6S ZjZ{6U_66{LZ>IW!$}wLMZUpL${{^4#H% "+dar+"/log/frpslog 2>&1 &" + os.system("pkill -9 frps") + system_start.del_Boot_up(cmd) + time.sleep(1) + os.system(cmd) + time.sleep(1) + if not get_process_id('frps'): + return errorjson(msg="启动失败,请检查配置") + system_start.insert_Boot_up(cmd=cmd,name="frps服务端") + elif types=='frpc': + cmd="cd "+dar +" && nohup ./frpc -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &" + os.system("pkill frpc") + system_start.del_Boot_up(cmd) + time.sleep(1) + os.system(cmd) + time.sleep(1) + if not get_process_id('frpc'): + return errorjson(msg="启动失败,请检查配置") + system_start.insert_Boot_up(cmd=cmd,name="frpc客户端") + return successjson() +def stop(types='all'): + "停止" + if types=='frps': + system_start.del_Boot_up("cd "+dar +" && nohup ./frps -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &") + os.system("pkill -9 frps") + elif types=='frpc': + system_start.del_Boot_up("cd "+dar +" && nohup ./frpc -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &") + os.system("pkill -9 frpc") + else: + system_start.del_Boot_up("cd "+dar +" && nohup ./frps -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &") + system_start.del_Boot_up("cd "+dar +" && nohup ./frpc -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &") + os.system("pkill -9 frps") + os.system("pkill -9 frpc") + return successjson() +def upd_server(types='ini'): + server=request.get_json() + if types=='ini': + file_set_content(dar+"/frps_full.ini",server['conf']) + elif types=='base': + base=server['base'] + f = open(dar+"/frps_full.ini") + con='' + while True: + line = f.readline() + if not line: + break + elif 'bind_addr = ' in line: + line="bind_addr = "+base['bind_addr']+"\n" + elif 'bind_port = ' in line: + line="bind_port = "+base['bind_port']+"\n" + elif 'bind_udp_port = ' in line: + line="bind_udp_port = "+base['bind_udp_port']+"\n" + elif 'kcp_bind_port = ' in line: + line="kcp_bind_port = "+base['kcp_bind_port']+"\n" + elif 'vhost_http_port = ' in line: + line="vhost_http_port = "+base['vhost_http_port']+"\n" + elif 'vhost_https_port = ' in line: + line="vhost_https_port = "+base['vhost_https_port']+"\n" + elif 'dashboard_addr = ' in line: + line="dashboard_addr = "+base['dashboard_addr']+"\n" + elif 'dashboard_port = ' in line: + line="dashboard_port = "+base['dashboard_port']+"\n" + elif 'dashboard_user = ' in line: + line="dashboard_user = "+base['dashboard_user']+"\n" + elif 'dashboard_pwd = ' in line: + line="dashboard_pwd = "+base['dashboard_pwd']+"\n" + elif 'log_level = ' in line: + line="log_level = "+base['log_level']+"\n" + elif 'log_max_days = ' in line: + line="log_max_days = "+base['log_max_days']+"\n" + elif 'disable_log_color = ' in line: + line="disable_log_color = "+base['disable_log_color']+"\n" + elif 'token = ' in line: + line="token = "+base['token']+"\n" + elif 'allow_ports = ' in line: + line="allow_ports = "+base['allow_ports']+"\n" + elif 'max_pool_count = ' in line: + line="max_pool_count = "+base['max_pool_count']+"\n" + elif 'max_ports_per_client = ' in line: + line="max_ports_per_client = "+base['max_ports_per_client']+"\n" + elif 'subdomain_host = ' in line: + line="subdomain_host = "+base['subdomain_host']+"\n" + elif 'tcp_mux = ' in line: + line="tcp_mux = "+base['tcp_mux']+"\n" + con=con+line + f.close() + file_set_content(dar+"/frps_full.ini",con) + file_set_content(dar+"/frps_full.conf",json_encode(base)) + os.system("pkill frps") + time.sleep(1) + os.system("cd "+dar +" && ./frps -c frps_full.ini &") + time.sleep(1) + if not get_process_id('frps'): + return errorjson(msg="启动失败,请检查配置") + return successjson() +def get_client(): + client={ + 'conf':file_get_content(dar+"/frpc.ini"), + 'base':json_decode(file_get_content(dar+"/frpc.conf")) + } + return successjson(client) +def upd_client(type='ini'): + server=request.get_json() + file_set_content(dar+"/frpc.ini",server['conf']) + os.system("pkill frpc") + time.sleep(1) + os.system("cd "+dar +" && ./frpc -c frpc.ini &") + time.sleep(1) + if not get_process_id('frpc'): + return errorjson(code=1,msg="启动失败,请检查配置") + return successjson() \ No newline at end of file diff --git a/app/intapp/controller/soft/index.py b/app/intapp/controller/soft/index.py new file mode 100644 index 0000000..54b9ced --- /dev/null +++ b/app/intapp/controller/soft/index.py @@ -0,0 +1,91 @@ +from .common import * +def index(): + return response.tpl('index/home') +def gettitle(title,edition): + "获取软件信息" + return successjson(sqlite('soft',model_intapp_soft_path).where("title='"+title+"' and edition='"+edition+"' and platform='"+get_sysinfo()['uname'][0]+"' and status >=4").find()) +def softlist(): + kw=request.args.get("kw") + pagenow=int(request.args.get("pagenow")) + pagesize=int(request.args.get("pagesize")) + return successjson(SOFT.softlist(kw,pagenow,pagesize)) +def updatesoftlist(): + "更新软件列表" + SOFT.updatesoftlist() + return successjson() +def getstatus(id): + "获取软件状态和描述" + return successjson(sqlite("soft",model_intapp_soft_path).field("status,msg").where("id",id).find()) +def insert(id): + "安装软件" + title=sqlite('soft',model_intapp_soft_path).where("id",id).field("title").find()['title'] + if 'nginx' == title: + ass=sqlite('soft',model_intapp_soft_path).where([('title','eq','nginx'),'and',('status','gt',0)]).find() + if ass: + return errorjson(msg="您已安装其他nginx版本,卸载其他nginx版本后可安装此版本") + if 'kodexplorer' in title or 'phpmyadmin' in title: + if not sqlite('soft',model_intapp_soft_path).where([('title','like','%php%'),'and',('status','egt','4')]).count() or not sqlite('soft',model_intapp_soft_path).where([('title','like','%nginx%'),'and',('status','egt','4')]).count(): + return errorjson(msg="先安装nginx和php") + if 'phpmyadmin' in title: + if not sqlite('soft',model_intapp_soft_path).where([('title','like','%mysql%'),'and',('status','egt','4')]).count() or not sqlite('soft',model_intapp_soft_path).where([('title','like','%nginx%'),'and',('status','egt','4')]).count(): + return errorjson(msg="先安装mysql") + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":1,"msg":"安装中"}) + Queues.insert(target=SOFT.insert,args=(id,),title="安装软件:"+title) + return successjson() +def start(id): + "启动软件" + SOFT.start(id) + return successjson() +def stop(id): + "停止软件" + SOFT.stop(id) + return successjson() +def restartnginx(): + """平滑重启nginx""" + os.system("nginx -s reload") + return successjson() + +def uninstall(id): + "卸载软件" + # title=request.args.get("title") + title=sqlite('soft',model_intapp_soft_path).where("id",id).field("title").find()['title'] + if 'nginx' == title: + sqlite("web",model_intapp_soft_path).where("1=1").update({"status":0}) + sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":5,"msg":"卸载中"}) + Queues.insert(target=SOFT.uninstall,args=(id,),title="卸载软件:"+title) + return successjson() + + +def gitssh(): + 'gitssh公钥' + try: + data=file_get_content("/root/.ssh/id_rsa.pub") + except: + data='' + return successjson(data) + + + +def add(): + "添加内容" + try: + data=request.get_json() + data.update(updtime=times(),addtime=times()) + # print(data) + sqlite('software',config.sqlitesoftware).insert(data) + except: + return errorjson(msg="失败") + else: + return successjson() +def update(id=0): + "更新内容" + data=request.get_json() + if not id: + id=data['id'] + try: + data.pop('updtime') + data.pop('addtime') + except:pass + else: + sqlite('software',config.sqlitesoftware).where("id",id).update(data) + return successjson() \ No newline at end of file diff --git a/app/intapp/controller/soft/install.txt b/app/intapp/controller/soft/install.txt new file mode 100644 index 0000000..bd02041 --- /dev/null +++ b/app/intapp/controller/soft/install.txt @@ -0,0 +1 @@ +oss2==2.2.0 \ No newline at end of file diff --git a/app/intapp/controller/soft/mongodb.py b/app/intapp/controller/soft/mongodb.py new file mode 100644 index 0000000..d444226 --- /dev/null +++ b/app/intapp/controller/soft/mongodb.py @@ -0,0 +1,247 @@ +from .common import * +import base64 +WORK_DIR="/data/mongodb" +# if not os.path.exists(WORK_DIR): +# os.system("mkdir -p "+WORK_DIR) +def get_config(id): + '获取mongodb页面配置' + try: + data=json_decode(file_get_content(WORK_DIR+"/config.conf")) + except: + data={} + try: + key=file_get_content(WORK_DIR+"/key/mongo.key") + except: + key="" + data['key']=key + data['get_local_ip']=get_local_ip() + data['WORK_DIR']=WORK_DIR + try: + data['configlist']=json_decode(file_get_content(WORK_DIR+"/serverconfig.conf")) + except: + data['configlist']={} + return successjson(data) +def upd_config(id): + '修改mongodb页面配置' + data=request.get_json() + os.system("mkdir -p "+WORK_DIR+"/key") + f=open(WORK_DIR+"/key/mongo.key","w") + f.write(data['key']) + f.close() + os.system("chmod 600 "+WORK_DIR+"/key/mongo.key") + data['key']='' + file_set_content(WORK_DIR+"/config.conf",json_encode(data)) + return successjson() + +def start_config(types='restart'): + '启动/停止config服务' + data=request.get_json() + data['key']='' + os.system("mkdir -p "+WORK_DIR+"/conf") + f=open(WORK_DIR+"/conf/config.conf","w") + f.write("logappend=true\n"+ + "fork=true\n"+ + "maxConns=5000\n"+ + "replSet=configs\n"+ + "keyFile="+WORK_DIR+"/key/mongo.key\n"+ + "configsvr=true") + f.close() + os.system("chmod 777 "+WORK_DIR+"/conf/config.conf") + # os.system("chmod 600 "+WORK_DIR+"/key/mongo.key") + i=1 + for k in data['configs']['server']: + os.system("mkdir -p "+WORK_DIR+"/config"+str(i)+"/data") + i+=1 + if types=='restart' or types=='stop': #停止服务 + i=1 + for k in data['configs']['server']: + pid=file_get_content(WORK_DIR+"/config"+str(i)+"/db.pid") + os.system("kill -9 "+str(pid)) + time.sleep(0.1) + i+=1 + data['configs']['serverstatus']=0 + if types=='restart' or types=='start': #启动服务 + i=1 + for k in data['configs']['server']: + startstatus=False + cmd="mongod --bind_ip "+str(k['ip'])+" --port "+str(k['port'])+" -f "+WORK_DIR+"/conf/config.conf --dbpath "+WORK_DIR+"/config"+str(i)+"/data --logpath "+WORK_DIR+"/config"+str(i)+"/log.log --pidfilepath "+WORK_DIR+"/config"+str(i)+"/db.pid" + result=os.popen(cmd) + res = result.read() + for line in res.splitlines(): + print("line",line) + if 'process started successfully' in line: + startstatus=True + break + if not startstatus: + return errorjson(code=1,msg="启动失败") + + i+=1 + data['configs']['serverstatus']=1 + file_set_content(WORK_DIR+"/config.conf",json_encode(data)) + return successjson() +def start_mongos(types='restart'): + '启动/停止路由服务' + data=request.get_json() + data['key']='' + # for k in data + #创建配置文件 + os.system("mkdir -p "+WORK_DIR+"/conf && mkdir -p "+WORK_DIR+"/mongos") + f=open(WORK_DIR+"/conf/mongos.conf","w") + f.write("logappend = true\n"+ + "fork=true\n"+ + data['mongos']['configdb']+" #这里必须是公共网ip或内网ip,千万不能是127.0.0.1\n" + "keyFile="+WORK_DIR+"/key/mongo.key\n"+ + "maxConns=20000 #最大连接数") + f.close() + os.system("chmod 777 "+WORK_DIR+"/conf/mongos.conf") + os.system("mkdir -p "+WORK_DIR+"/mongos") + if types=='restart' or types=='stop': #停止服务 + i=1 + for k in data['mongos']['server']: + pid=file_get_content(WORK_DIR+"/mongos/db"+str(i)+".pid") + os.system("kill -9 "+str(pid)) + time.sleep(0.1) + i+=1 + data['mongos']['serverstatus']=0 + if types=='restart' or types=='start': #启动服务 + i=1 + for k in data['mongos']['server']: + startstatus=False + cmd="mongos --bind_ip "+str(k['ip'])+" --port "+str(k['port'])+" -f "+WORK_DIR+"/conf/mongos.conf --logpath "+WORK_DIR+"/mongos/log"+str(i)+".log --pidfilepath "+WORK_DIR+"/mongos/db"+str(i)+".pid" + print(cmd) + result=os.popen(cmd) + res = result.read() + for line in res.splitlines(): + print("line",line) + if 'process started successfully' in line: + startstatus=True + break + if not startstatus: + return errorjson(code=1,msg="启动失败") + i+=1 + data['mongos']['serverstatus']=1 + file_set_content(WORK_DIR+"/config.conf",json_encode(data)) + return successjson() +def start_shard(types='restart'): + '启动/停止分片服务' + data=request.get_json() + data['key']='' + os.system("mkdir -p "+WORK_DIR+"/conf") + + j=1 + for shard in data['shard']:#分片列表 + f=open(WORK_DIR+"/conf/shard"+str(j)+".conf","w") + f.write("logappend=true\n"+ + "fork=true\n"+ + "maxConns=2000\n"+ + "storageEngine=mmapv1 #基于内存映射文件的存储引擎\n"+ + "shardsvr=true\n"+ + "replSet="+shard['servername']+"\n"+ + "keyFile="+WORK_DIR+"/key/mongo.key") + f.close() + i=1 + for k in shard['server']: + os.system("mkdir -p "+WORK_DIR+"/shard"+str(j)+"/data"+str(i)) + i+=1 + if types=='restart' or types=='stop': #停止服务 + i=1 + for k in shard['server']: + pid=file_get_content(WORK_DIR+"/shard"+str(j)+"/db"+str(i)+".pid") + os.system("kill -9 "+str(pid)) + time.sleep(0.1) + i+=1 + data['shard'][j-1]['serverstatus']=0 + if types=='restart' or types=='start': #启动服务 + i=1 + for k in shard['server']:#副本集列表 + startstatus=False + cmd="mongod --bind_ip "+str(k['ip'])+" --port "+str(k['port'])+" -f "+WORK_DIR+"/conf/shard"+str(j)+".conf --dbpath "+WORK_DIR+"/shard"+str(j)+"/data"+str(i)+" --logpath "+WORK_DIR+"/shard"+str(j)+"/log"+str(i)+".log --pidfilepath "+WORK_DIR+"/shard"+str(j)+"/db"+str(i)+".pid" + print("启动cmd:",cmd) + result=os.popen(cmd) + res = result.read() + for line in res.splitlines(): + print("line",line) + if 'process started successfully' in line: + startstatus=True + break + if not startstatus: + file_set_content(WORK_DIR+"/config.conf",json_encode(data)) + return errorjson(code=1,msg="启动失败") + i+=1 + data['shard'][j-1]['serverstatus']=1 + j+=1 + file_set_content(WORK_DIR+"/config.conf",json_encode(data)) + return successjson() + +# def config_init(id): +# "config副本集初始化," +# data=request.get_json() +# port=data['configs']['server'][0]['port'] +# replicaset=data['configs']['replicaset'] +# members=[] +# i=0 +# for k in replicaset: +# zd={'_id':i,'host':k['ip']+':'+str(k['port'])} +# members.append(zd) +# i+=1 +# f=open(config.path['path']+"app/linuxweb/config_init.sh","w") +# f.write("mongo --port "+str(port)+"\n"+ +# "use admin\n"+ +# "rs.initiate({_id:'configs',members:"+json_encode(members)+"})\n"+ +# "exit") +# f.close() +# os.system("cd "+config.path['path']+"app/linuxweb && bash config_init.sh") +# return successjson() + + + +#mongodb独立部署 /data/mongodb/server1/ +def setserverconfig(): + configlist=request.get_json() + for k in configlist: + if not os.path.exists(WORK_DIR+k['path']): + os.makedirs(WORK_DIR+k['path']) + if not os.path.exists(WORK_DIR+k['path']+"/data"): + os.makedirs(WORK_DIR+k['path']+"/data") + file_set_content(WORK_DIR+k['path']+"/mongod.config",''+ + 'systemLog:\n'+ + ' destination: file\n'+ + ' logAppend: true\n'+ + ' path: '+WORK_DIR+k['path']+'/mongodb.log #mongodb的日志文件路径\n'+ + 'storage:\n'+ + ' dbPath: '+WORK_DIR+k['path']+'/data/ #mongodb的数据文件路径\n'+ + ' journal:\n'+ + ' enabled: true\n'+ + 'processManagement:\n'+ + ' fork: true # fork and run in background\n'+ + ' pidFilePath: '+WORK_DIR+k['path']+'/mongod.pid # location of pidfile\n'+ + ' timeZoneInfo: /usr/share/zoneinfo\n'+ + 'net:\n'+ + ' port: '+str(k['port'])+' #mongodb1的进程号\n'+ + ' bindIp: '+k['bindIp']+' # Listen to local interface only, comment to listen on all interfaces') + file_set_content(WORK_DIR+"/serverconfig.conf",json_encode(configlist)) + return successjson() +def restartserver(types='start',index=0): + index=int(index) + configlist=json_decode(file_get_content(WORK_DIR+"/serverconfig.conf")) + cmd="mongod -f "+WORK_DIR+configlist[index]['path']+"/mongod.config" #启动命令 + if types=='start': + configlist[index]['status']=1 + system_start.insert_Boot_up(cmd=cmd,name="mongodb独立模式") + elif types=='stop': + configlist[index]['status']=0 + system_start.del_Boot_up(cmd) + cmd=cmd+" --shutdown" #停止命令 + result=os.popen(cmd) + res = result.read() + startstatus=False + for line in res.splitlines(): + print("line",line) + if 'process started successfully' in line or 'killing process with pid' in line: + startstatus=True + break + if startstatus: + file_set_content(WORK_DIR+"/serverconfig.conf",json_encode(configlist)) + return successjson() + else: + return errorjson(cmd,msg="失败") diff --git a/app/intapp/controller/soft/mysql.py b/app/intapp/controller/soft/mysql.py new file mode 100644 index 0000000..114b3bb --- /dev/null +++ b/app/intapp/controller/soft/mysql.py @@ -0,0 +1,254 @@ +from .common import * +import oss2 +def get_data(id): + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + text=file_get_content(ar['paths']+ar['title']+ar['edition']+"/config.conf") + conf=json_decode(text) + if not conf: + conf={ + "base":{'rootpassword':'intapppasswordtest','path':ar['paths']+ar['title']+ar['edition']+'/data'}, + } + data={ + 'conf':conf, + 'ar':ar, + "my":file_get_content("/etc/my.cnf") + } + return successjson(data) +def upd_my(): + "修改配置文件" + data=request.get_json() + file_set_content("/etc/my.cnf",data['text']) + return successjson() +def upd_data(id): + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + data=request.get_json() + filetext=file_get_content(ar['paths']+ar['title']+ar['edition']+"/config.conf") + filedata=json_decode(filetext) + if not filedata or data['base']['rootpassword']!=filedata['base']['rootpassword']:#修改mysql密码 + os.system("mysqld restart --skip-grant-tables") + cmd="mysql -uroot -e " + cmd=cmd+'"use mysql;flush privileges;update user set authentication_string=password(' + cmd=cmd+"'"+str(data['base']['rootpassword']) + cmd=cmd+"'" + cmd=cmd+') where user=' + cmd=cmd+"'root';set password=password('"+str(data['base']['rootpassword'])+"');" + cmd=cmd+'"' + pi=subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) + ars=pi.stdout.read().decode() + ars=ars.split("\n") + strs=ars[len(ars)-2] + os.system("mysqld restart") + print(type(strs),strs) + if 'error' in strs: + return errorjson(msg="密码修改失败"+strs) + + # mysqld restart --skip-grant-tables && mysql -uroot -e "flush privileges;update mysql.user set authentication_string=password('123456') where user = 'root'"; + # print(data['base']['rootpassword'],filedata['base']['rootpassword']) + if not filedata or data['base']['path']!=filedata['base']['path']: + os.system('mysqld stop') + os.system("mkdir -p "+str(data['base']['path'])) + if not filedata: + print("cp -r "+ar['paths']+ar['title']+ar['edition']+"/data/. "+data['base']['path']+"/") + os.system("cp -r "+ar['paths']+ar['title']+ar['edition']+"/data/. "+data['base']['path']+"/") + else: + print("cp -r "+filedata['base']['path']+"/. "+data['base']['path']+"/") + os.system("cp -r "+filedata['base']['path']+"/. "+data['base']['path']+"/") + os.system("chown -R mysql "+str(data['base']['path'])+" && chgrp -R mysql "+str(data['base']['path'])) + + f = open('/etc/my.cnf') + con='' + while True: + line = f.readline() + if not line: + break + elif 'datadir=' in line: + line="datadir="+str(data['base']['path'])+"\n" + con=con+line + f.close() + f= open('/etc/my.cnf', "w") + f.write(con) + f.close() + time.sleep(1) + os.system('mysqld start') + text=json_encode(data) + file_set_content(ar['paths']+ar['title']+ar['edition']+"/config.conf",text) + + return successjson() +def backups(types='whole',db='bankup_all_databases',upload_aliyun=True): + "备份mysql" + return BACKUP.backups(types,db,upload_aliyun) +def recovery(types='whole',upload_aliyun=True): + "恢复mysql" + db=request.args.get("db") + Queues.insert(target=BACKUP.recovery,args=(types,db,upload_aliyun),title="恢复mysql") + return successjson(msg="正在恢复数据库,请在任务队列中查看恢复结果") +class BACKUP: + def recovery(types,db,upload_aliyun): + """恢复数据库""" + if not os.path.isfile("app/common/file/config.conf"): + print("在系统配置中保存备份目录") + return + fileconfig=json_decode(file_get_content("app/common/file/config.conf")) + if not fileconfig: + print("在系统配置中保存备份目录") + return + backpath=fileconfig['aliyun']['backpath'] + if backpath: + if backpath[:1]=='/': + backpath=backpath[1:] + if backpath[-1]=='/': + backpath=backpath[:-1] + else: + backpath="kcweb" + backmysqlpath="backup/mysql" #mysql备份目录 + if not os.path.exists(backmysqlpath): + os.makedirs(backmysqlpath) + mysqlpwd='intapppasswordtest' + mysqlconf=json_decode(file_get_content("/usr/local/mysql/mysql5.7/config.conf")) #mysql信息 + if mysqlconf: + mysqldatapath=mysqlconf['base']['path'] + mysqlpwd=mysqlconf['base']['rootpassword'] + conf={ + "mysql":{ + "username":"root","password":mysqlpwd,"host":"127.0.0.1",#mysql信息 + }, + } + if upload_aliyun: + auth = oss2.Auth(fileconfig['aliyun']['access_key'],fileconfig['aliyun']['access_key_secret']) + bucket = oss2.Bucket(auth,fileconfig['aliyun']['address'],fileconfig['aliyun']['bucket']) + bucket.get_object_to_file(db,backmysqlpath+"/database.sql.gz") + os.system("gzip -d "+backmysqlpath+"/database.sql.gz") + os.system("mysql -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" < "+backmysqlpath+"/database.sql") + os.remove(backmysqlpath+"/database.sql") + else: + os.system("gzip -d "+backmysqlpath+"/"+db+".sql.gz") + os.system("mysql -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" < "+backmysqlpath+"/"+db+".sql") + print("恢复完成") + def backups(types,db,upload_aliyun): + """备份mysql --cli运行 + types whole表示全量备份。 increment表示增量备份所有 + + db bankup_all_databases表示备份所有数据库。 否则备份指定数据库按逗号分隔 types=whole时有效 + """ + if not os.path.isfile("app/common/file/config.conf"): + print("在系统配置中保存备份目录") + return + fileconfig=json_decode(file_get_content("app/common/file/config.conf")) + if not fileconfig: + print("在系统配置中保存备份目录") + return + backpath=fileconfig['aliyun']['backpath'] + if backpath: + if backpath[:1]=='/': + backpath=backpath[1:] + if backpath[-1]=='/': + backpath=backpath[:-1] + else: + backpath="kcweb" + backmysqlpath="backup/mysql" #mysql备份目录 + if not os.path.exists(backmysqlpath): + os.makedirs(backmysqlpath) + mysqldatapath="/usr/local/mysql/mysql5.7/data" #mysql数据库存放目 + mysqlpwd='intapppasswordtest' + mysqlconf=json_decode(file_get_content("/usr/local/mysql/mysql5.7/config.conf")) #mysql信息 + if mysqlconf: + mysqldatapath=mysqlconf['base']['path'] + mysqlpwd=mysqlconf['base']['rootpassword'] + conf={ + "mysql":{ + "username":"root","password":mysqlpwd,"host":"127.0.0.1",#mysql信息 + }, + } + if upload_aliyun: + auth = oss2.Auth(fileconfig['aliyun']['access_key'],fileconfig['aliyun']['access_key_secret']) + bucket = oss2.Bucket(auth,fileconfig['aliyun']['address'],fileconfig['aliyun']['bucket']) + if types=='whole': #全量备份 + if not os.path.exists(backmysqlpath): + os.system("mkdir -p "+backmysqlpath) + if db=='bankup_all_databases':#备份所有 + print("全量备份所有数据库:"+db+".sql.gz") + os.system("mysqldump -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" --all-databases --flush-logs --delete-master-logs --single-transaction | gzip >> "+backmysqlpath+"/"+db+".sql.gz") + else:#备份指定数据库 + db=re.sub(","," ",db) + print("全量备份指定数据库:"+db+".sql.gz") + os.system("mysqldump -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" --databases --flush-logs --delete-master-logs --single-transaction | gzip >> "+backmysqlpath+"/"+db+".sql.gz") + if upload_aliyun: + print(backmysqlpath+"/"+db+".sql.gz","上传mysql备份目录文件到阿里云oss...") + oss2.resumable_upload(bucket, "backups/"+backpath+"/"+backmysqlpath+"/"+db+"/"+time.strftime("%Y%m%d-%H:%M:%S",time.localtime(times()))+".sql.gz",backmysqlpath+"/"+db+".sql.gz") + filelist=[] + for obj in oss2.ObjectIterator(bucket, prefix="backups/"+backpath+"/"+backmysqlpath+"/"+db+"/"): + filelist.append(obj.key) + i=0 + while True: + if len(filelist)-i <= 5: #在阿里云保留5个备份文件 其他上传 + break + bucket.delete_object(filelist[i]) + i+=1 + + # elif types=='increment': #增量备份所有 + # if not os.path.exists(backmysqlpath) or not os.path.isfile(backmysqlpath+"/"+db+".sql.gz"): + # os.system("mkdir -p "+backmysqlpath) + # print("全量备份所有数据库:"+db+".sql.gz") + # os.system("mysqldump -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" --all-databases --flush-logs --delete-master-logs --single-transaction | gzip >> "+backmysqlpath+"/increment_all_databases.sql.gz") + # print("备份mysql二进制文件...") + # t=os.listdir(backmysqlpath) + # lis=os.listdir(mysqldatapath) + # maxlist=[] + # for files in lis: + # if 'mysql-bin.' in files: + # try: + # a=int(files.replace("mysql-bin.", "")) + # maxlist.append(a) + # except:pass + # for files in lis: + # iscz=True #是否需要复制 + # if iscz: + # for k in t: + # if mysqldatapath+"/"+k == mysqldatapath+"/"+files: + # iscz=False + # print(mysqldatapath+"/"+k+"已存在") + # break + # if not iscz: + # if 'mysql-bin.' in files: + # try: + # a=int(files.replace("mysql-bin.", "")) + # if max(maxlist) == a: + # iscz=True + # print(mysqldatapath+"/"+files+"该文件是最后一个日志,已备份,(最后一个文件可能不是完整的)") + # except:pass + # if iscz: + # if 'mysql-bin.' in files: + # try: + # a=int(files.replace("mysql-bin.", "")) + # os.system("cp -f "+mysqldatapath+"/"+files+" "+backmysqlpath+"/"+files) + # print("cp -f "+mysqldatapath+"/"+files+" "+backmysqlpath+"/"+files,"复制成功") + # except:pass + # if upload_aliyun: + # print("上传mysql备份目录文件到阿里云oss...") + # t=os.listdir(backmysqlpath) + # maxlist=[] + # for files in t: + # if 'mysql-bin.' in files: + # try: + # a=int(files.replace("mysql-bin.", "")) + # maxlist.append(a) + # except:pass + # path=get_file(backmysqlpath,is_folder=False) + # for files in path: + # sc=True #是否需要上传 + # if bucket.object_exists("backups/"+files['path']):#如果文件已存在阿里云 + # if 'mysql-bin.' in files['name']: + # try: + # a=int(files['name'].replace("mysql-bin.", "")) + # if max(maxlist) == a: + # print(backmysqlpath+"/"+files['name']+"该文件是最后一个日志,所以要上传阿里云") + # else: + # print("文件已在阿里云oss存在") + # sc=False + # except:pass + # else: + # print("文件已在阿里云oss存在") + # sc=False + # if sc: + # oss2.resumable_upload(bucket, "backups/"+files['path'], files['path']) + print("备份完成") diff --git a/app/intapp/controller/soft/nginx.py b/app/intapp/controller/soft/nginx.py new file mode 100644 index 0000000..09e4418 --- /dev/null +++ b/app/intapp/controller/soft/nginx.py @@ -0,0 +1,360 @@ +from .common import * +import traceback +def index(id='',types='getinfo'): + "nginx配置文件" + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + paths=ar['paths'] + filenames=ar['title'] + edition=ar['edition'] + if types=='getinfo': + if os.path.isfile(paths+filenames+edition+'/logs/error.log'): + # print(paths+filenames+'/logs/error.log') + # f=open(paths+filenames+'/logs/error.log','r') + # logserror=f.read() + # f.close() + logserror='' + else:logserror='' + if os.path.isfile(paths+filenames+edition+'/logs/access.log'): + # f=open(paths+filenames+'/logs/access.log','r',encoding="utf-8") + # logsaccess=f.read() + # f.close() + logsaccess='' + else:logsaccess='' + f=open(paths+filenames+edition+'/conf/nginx.conf','r',encoding="utf-8") + confnginx=f.read() + data={ + 'logs':{'error':logserror,'access':logsaccess}, + 'conf':{'nginx':confnginx}, + } + return successjson(data) + elif types=='updconf': + con=request.get_json() + f=open(paths+filenames+edition+'/conf/nginx.conf','w',encoding="utf-8") + f.write(con['text']) + f.close() + return successjson() + else: + return errorjson(msg="未知类型") +def anphp(): + "已安装的php以及伪静态模板" + nginx=sqlite('soft',model_intapp_soft_path).where([('status','egt','4'),'and',('platform','eq',get_sysinfo()['uname'][0]),'and',('title','like','nginx%')]).find() + if nginx: + pseudo_static_tpl=get_file(nginx['paths']+nginx['title']+nginx['edition']+'/conf/vhost/webtpl/rewrite') #伪静态模板 + rewr=[] + for k in pseudo_static_tpl: + rewr.append({'name':k['name'],'text':file_get_content(k['path'])}) + data={ + "php":sqlite('soft',model_intapp_soft_path).where("title like '%php%' and (status=4 or status=10) and title not like '%phpmyadmin%'").select(), + "rewr":rewr + } + return successjson(data) + else: + return successjson() +def webdescribesfind(): + "获取指定网站信息" + title=request.args.get("title") + return successjson(sqlite("web",model_intapp_soft_path).where("title='"+title+"'").find()) +def weblist(): + "网站列表" + where=False + pagenow=int(request.args.get('pagenow')) + pagesize=int(request.args.get('pagesize')) + kw=request.args.get('kw') + if kw: + where=[("title","like","%"+str(kw)+"%"),'or',("describes","like","%"+str(kw)+"%"),'or',("domain","like","%"+str(kw)+"%")] + if not pagenow: + pagenow=1 + if not pagesize: + pagesize=10 + lists=sqlite("web",model_intapp_soft_path).where(where).page(pagenow,pagesize).select() + i=0 + for k in lists: + # lists[i]['domain']=k['domain'].split("\n") + lists[i]['balancing'] =json_decode(k['balancing']) + lists[i]['proxy_set_header'] =json_decode(k['proxy_set_header']) + lists[i]['header'] =json_decode(k['header']) + i+=1 + count=sqlite("web",model_intapp_soft_path).where(where).count() + return successjson(return_list(lists,count,pagenow,pagesize)) +def add_web(): + "添加或更新网站" + nginx=sqlite('soft',model_intapp_soft_path).where([('status','egt','4'),'and',('platform','eq',get_sysinfo()['uname'][0]),'and',('title','like','nginx%')]).find() + if not nginx: + return errorjson(msg='安装nginx服务器后才创建网站') + addtime=times() + data=request.get_json() + if data['domain']=='': + return errorjson(msg="域名不能为空") + if data['port']=='': + return errorjson(msg="端口不能为空") + if data['client_max_body_size']=='': + return errorjson(msg="上传限制不能为空") + if data['path']=='': + data['path']="/www/wwwroot/" + # return errorjson(msg="网站目录不能为空") + paths=nginx['paths'] + try: + ttt1=data['domain'].split("\n") + if data['id']: + where="port="+str(data['port'])+" and id != "+str(data['id'])+" and (" #[('port','eq',data['port'])] + for kk in ttt1: + where=where+"domain like '%"+kk+"%'"+" or " + where=where[:-4]+")" + ttt2=sqlite('web',model_intapp_soft_path).where(where).find() + if ttt2: + ttt2=ttt2['domain'].split("\n") + for k in ttt2: + for kk in ttt2: + if k==kk: + return errorjson(msg=k+"已在本服务器其他站点使用被使用") + domains=sqlite('web',model_intapp_soft_path).where("id",data['id']).field("only").find()['only'] + else: + where="port="+data['port']+" and (" + for kk in ttt1: + where=where+"domain like '%"+kk+"%'"+" or " + where=where[:-4]+")" + domains=ttt1[0]+":"+str(data['port']) + data['only']=domains + ttt=sqlite('web',model_intapp_soft_path).where(where).find() + if ttt: + ttt=ttt['domain'].split("\n") + for k in ttt: + for kk in ttt1: + if k==kk: + return errorjson(msg=k+"已被使用") + ttt=data['domain'].split("\n") + server_name='' + for k in ttt: + server_name=str(server_name)+" "+str(k) + + if nginx['platform']=='Linux': + if data['webtpl']=='': + return errorjson(msg="请选择配置文件模板") + filenames=nginx['title']+nginx['edition'] + servertpl=paths+filenames+'/conf/vhost/webtpl/'+data['webtpl'] + ssl_certificate="" + ssl_certificate_key="" + try: + ssl_certificate=data['ssl_certificate'] + ssl_certificate_key=data['ssl_certificate_key'] + except: + data['ssl_certificate']='' + data['ssl_certificate_key']='' + try: + data['header'] + except: + data['header']='' + try: + data['ssl'] + except: + data['ssl']='' + try: + data['rewrite'] + except: + data['rewrite']='' + if data['ssl']: + ssl=443 + if len(data['ssl_certificate'])>5 and len(data['ssl_certificate_key'])>5: + ssl_certificate=data['ssl_certificate'] + ssl_certificate_key=data['ssl_certificate_key'] + # print(ssl_certificate_key) + else: + key=paths+filenames+'/conf/vhost/rewrite/'+domains+".key" + pem=paths+filenames+'/conf/vhost/rewrite/'+domains+".pem" + file_set_content(key,data['key']) + file_set_content(pem,data['pem']) + ssl_certificate=paths+filenames+"/conf/vhost/rewrite/"+domains+".pem" + ssl_certificate_key=paths+filenames+"/conf/vhost/rewrite/"+domains+".key" + print(ssl_certificate) + else: + if os.path.isfile(paths+filenames+'/conf/vhost/rewrite/'+domains+".key") and os.path.isfile(paths+filenames+'/conf/vhost/rewrite/'+domains+".pem"): + sslttt1=file_get_content(paths+filenames+'/conf/vhost/rewrite/'+domains+".key") + sslttt2=file_get_content(paths+filenames+'/conf/vhost/rewrite/'+domains+".pem") + if len(sslttt1)>10 and len(sslttt2)>10: + ssl=443 + else: + ssl=False + else: + ssl=False + if 'php' in data['webtpl'] and len(data['rewrite'])>4:#php伪静态 + file_set_content(paths+filenames+"/conf/vhost/rewrite/"+domains,data['rewrite']) + elif not os.path.isfile(paths+filenames+"/conf/vhost/rewrite/"+domains): + file_set_content(paths+filenames+"/conf/vhost/rewrite/"+domains,'') + if data['webtpl']=='static' or data['webtpl']=='vue' or 'php' in data['webtpl']: + + text=Templates(servertpl,client_max_body_size=data['client_max_body_size'],port=data['port'],ssl=ssl,ssl_certificate=ssl_certificate,ssl_certificate_key=ssl_certificate_key, + server_name=server_name,webpath=data['path'],rewrite=paths+filenames+"/conf/vhost/rewrite/"+domains,domains=domains,header=data['header']) + elif data['webtpl']=='balancing':#添加负载均衡 + balancing=data['balancing'] #负载均衡列表 + proxy_set_header=data['proxy_set_header'] #自定义转发请求头列表 + for k in data['balancing']: + if k['ip']=='' or k['port']=='': + return errorjson(msg="请填写负载均衡ip和端口") + text=Templates(servertpl,client_max_body_size=data['client_max_body_size'],port=data['port'],ssl=ssl,balancing=balancing,proxy_set_header=proxy_set_header,ssl_certificate=ssl_certificate,ssl_certificate_key=ssl_certificate_key, + server_name=server_name,webpath=data['path'],rewrite=paths+filenames+"/conf/vhost/rewrite/"+domains,domains=domains,header=data['header']) + f=open(paths+filenames+"/conf/vhost/"+domains+'.conf','w',encoding="utf-8") + f.write(text) + f.close() + os.system("nginx -s reload") + if not os.path.exists(data['path']): + os.makedirs(data['path']) + f=open(data['path']+"/index.html",'w',encoding="utf-8") + f.write('网站创建成功

恭喜您!网站创建成功

') + f.close() + f=open(data['path']+"/index.php",'w',encoding="utf-8") + f.write("") + f.close() + try: + data['servers']=paths+filenames + except:pass + try: + del data['key'] + del data['pem'] + except:pass + del data['ssl'] + del data['rewrite'] + data['balancing'] =json_encode(data['balancing']) + data['proxy_set_header'] =json_encode(data['proxy_set_header']) + data['header'] =json_encode(data['header']) + if data['id']: + data['updtime']=addtime + data['status']=1 + sqlite('web',model_intapp_soft_path).where("id",data['id']).update(data) + pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) + ars=pi.stdout.read().decode() + ars=ars.split("\n") + strs=ars[len(ars)-2] + if len(strs) > 1: + return errorjson(msg=strs) + else: + del data['id'] + data['addtime']=addtime + data['updtime']=addtime + sqlite('web',model_intapp_soft_path).insert(data) + except: + print(traceback.format_exc()) + return errorjson(msg="失败,检查参数是否有误") + else: + return successjson() +def del_web(id=0,path=0): + #path=1 表示删除网站目录 ,linux和windows已完成 + "删除网站" + title=request.args.get("title") + if not id and title: + where="title = '"+title+"'" + else: + where="id='"+str(id)+"'" + nginx=sqlite('web',model_intapp_soft_path).where(where).find() + if not nginx: + return successjson(msg="不存在") + print(nginx) + filenames=nginx['servers'] + if get_sysinfo()['uname'][0]=='Linux': + if os.path.isfile(filenames+"/conf/vhost/"+nginx['only']+'.conf'): + os.remove(filenames+"/conf/vhost/"+nginx['only']+'.conf') + if os.path.isfile(filenames+"/conf/vhost/rewrite/"+nginx['only']): + os.remove(filenames+"/conf/vhost/rewrite/"+nginx['only']) + if os.path.isfile(filenames+"/logs/"+nginx['only']+".access.log"): + os.remove(filenames+"/logs/"+nginx['only']+".access.log") + if os.path.isfile(filenames+'/conf/vhost/rewrite/'+nginx['only']+".key"): + os.remove(filenames+'/conf/vhost/rewrite/'+nginx['only']+".key") + if os.path.isfile(filenames+'/conf/vhost/rewrite/'+nginx['only']+".pem"): + os.remove(filenames+'/conf/vhost/rewrite/'+nginx['only']+".pem") + pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) + ars=pi.stdout.read().decode() + ars=ars.split("\n") + strs=ars[len(ars)-2] + elif get_sysinfo()['uname'][0]=='Windows': + if os.path.isfile(filenames+"/conf/vhost/"+nginx['only']+'.conf'): + os.remove(filenames+"/conf/vhost/"+nginx['only']+'.conf') + if os.path.isfile(filenames+"/conf/vhost/rewrite/"+nginx['only']): + os.remove(filenames+"/conf/vhost/rewrite/"+nginx['only']) + if os.path.isfile(filenames+"/logs/"+nginx['only']+".access.log"): + os.remove(filenames+"/logs/"+nginx['only']+".access.log") + os.system("cd "+filenames+" & stop.bat") + time.sleep(3) + os.system("cd "+filenames+" & start.bat") + else: + return errorjson(msg="无法匹配系统") + if path=='1' and os.path.exists(nginx['path']): + shutil.rmtree(nginx['path']) + sqlite('web',model_intapp_soft_path).where(where).delete() + pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) + ars=pi.stdout.read().decode() + ars=ars.split("\n") + strs=ars[len(ars)-2] + if len(strs) > 1: + return errorjson(msg=strs) + return successjson() + +def getssl(id): + ar=sqlite('web',model_intapp_soft_path).where('id',id).find() + key=ar['servers']+'/conf/vhost/rewrite/'+ar['only']+".key" + pem=ar['servers']+'/conf/vhost/rewrite/'+ar['only']+".pem" + data={ + "key":file_get_content(key), + "pem":file_get_content(pem) + } + return successjson(data) +def getrewr(id): + "获取伪静态" + ar=sqlite('web',model_intapp_soft_path).where('id',id).find() + return successjson(file_get_content(ar['servers']+'/conf/vhost/rewrite/'+ar['only'])) +def getconfig(id,types='get'): + "获取配置文件" + ar=sqlite('web',model_intapp_soft_path).where('id',id).find() + if types=='get': + return successjson(file_get_content(ar['servers']+'/conf/vhost/'+ar['only']+".conf")) + elif types=='set': + data=request.get_json() + file_set_content(ar['servers']+'/conf/vhost/'+ar['only']+".conf",data['text']) + pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) + ars=pi.stdout.read().decode() + ars=ars.split("\n") + strs=ars[len(ars)-2] + if len(strs) > 1: + return errorjson(msg=strs) + return successjson() + + +def sslfolde(): + "Let's Encrypt证书夹" + paths="/etc/letsencrypt/live/" + if not os.path.exists(paths): + return errorjson(code=1,msg="Let's Encrypt证书夹不存在,在插件市场安装LetsEncrypt插件创建证书后再使用该功能") + try: + lis=os.listdir(paths) + except: + return errorjson(code=1,msg="无法打开"+str(paths)) + lists=[] + for files in lis: + types="folder" + config={} + if os.path.isfile(paths+"/"+files): + types="file" + else: + config=file_get_content(paths+"/"+files+"/config.conf") + if config: + config=json_decode(config) + zd={"name":files,"types":types,"config":config} + lists.append(zd) + data=return_list(lists,count=len(lis),pagenow=1,pagesize=len(lis)) + data['paths']=paths + "文件列表" + return successjson(data) +def ssltpl(): + "Let's Encrypt证书内容" + name=request.args.get("name") + paths="/etc/letsencrypt/live/"+name + chain=file_get_content(paths+"/chain.pem") + fullchain=file_get_content(paths+"/fullchain.pem") + privkey=file_get_content(paths+"/privkey.pem") + cert=file_get_content(paths+"/cert.pem") + data={ + "chain":chain, + "fullchain":fullchain, + "privkey":privkey, + "cert":cert + } + return successjson(data) + \ No newline at end of file diff --git a/app/intapp/controller/soft/page.py b/app/intapp/controller/soft/page.py new file mode 100644 index 0000000..0dc48f6 --- /dev/null +++ b/app/intapp/controller/soft/page.py @@ -0,0 +1,13 @@ +from .common import * +def home(): + return response.tpl("index/home") +def pub(html): + return response.tpl("page/%s" % html) +def s(fun,html): + id=request.args.get("id") + return response.tpl("%s/%s" % (fun,html),id=id) +def soft(html): + id=request.args.get("id") + types=request.args.get("types") + data=sqlite("soft",model_intapp_soft_path).where("id",id).find() + return response.tpl("soft/%s" % html,id=id,data=data,types=types) \ No newline at end of file diff --git a/app/intapp/controller/soft/php.py b/app/intapp/controller/soft/php.py new file mode 100644 index 0000000..5c1e94b --- /dev/null +++ b/app/intapp/controller/soft/php.py @@ -0,0 +1,266 @@ +from .common import * +def ini(id,is_upd=0): + "php.ini配置文件" + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + paths=ar['paths'] + filenames=ar['title']+ar['edition'] + if ar['platform']=='Linux': + filepath=paths+filenames+"/bin/php.ini" + elif ar['platform']=='Windows': + filepath=paths+filenames+"/php.ini" + else: + return errorjson(code=1,msg="不支持此时平台") + if is_upd: #修改配置 + data=request.get_json() + file_set_content(filepath,data['text']) + return successjson() + else: + data={ + 'ini':file_get_content(filepath), + 'php':ar + } + return successjson(data) +def www_conf(id,is_upd=0): + "www.conf配置文件" + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + paths=ar['paths'] + filenames=ar['title']+ar['edition'] + if ar['platform']=='Linux': + filepath=paths+filenames+"/etc/php-fpm.d/www.conf" + if 'php5.6' in filenames: + filepath=paths+filenames+"/etc/php-fpm.conf" + elif ar['platform']=='Windows': + filepath='' + else: + return errorjson(code=1,msg="不支持此时平台") + if is_upd: #修改配置 + data=request.get_json() + file_set_content(filepath,data['text']) + return successjson() + else: + data={ + 'www_conf':file_get_content(filepath), + 'php':ar + } + return successjson(data) +def phpfpm(id,is_upd=0): + "phpfpm配置信息" + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + paths=ar['paths'] + filenames=ar['title']+ar['edition'] + if ar['platform']=='Linux': + if not os.path.exists(paths+filenames+"/bin/conf"): + os.makedirs(paths+filenames+"/bin/conf") + filepath=paths+filenames+"/bin/conf/phpfpm.conf" + phpfpmpath=paths+filenames+"/etc/php-fpm.d/www.conf" + if 'php5.6' in filenames: + phpfpmpath=paths+filenames+"/etc/php-fpm.conf" + else: + filepath='' + phpfpmpath='' + if is_upd: #修改php-fpm配置信息 + data=request.get_json() + f = open(phpfpmpath) + con='' + while True: + line = f.readline() + if not line: + break + elif 'pm = ' in line and '=' in line: #运行描述 + line="pm = "+data['text']['pm']+"\n" + elif 'pm.max_children' in line and '=' in line:# 允许创建的最大子进程数 + line="pm.max_children = "+data['text']['max_children']+"\n" + elif 'pm.start_servers' in line and '=' in line:# 起始进程数(服务启动后初始进程数量) + line="pm.start_servers = "+data['text']['start_servers']+"\n" + elif 'pm.min_spare_servers' in line and '=' in line:# 起始进程数(服务启动后初始进程数量) + line="pm.min_spare_servers = "+data['text']['min_spare_servers']+"\n" + elif 'pm.max_spare_servers' in line and '=' in line:# 最大空闲进程数(当空闲进程达到此值时清理) + line="pm.max_spare_servers = "+data['text']['max_spare_servers']+"\n" + con=con+line + f.close() + f= open(phpfpmpath, "w") + f.write(con) + f.close() + file_set_content(filepath,json_encode(data['text'])) + return successjson() + else: + phpfpm=json_decode(file_get_content(filepath)) + if not phpfpm: + phpfpm='' + data={ + 'phpfpm':phpfpm, + 'php':ar + } + return successjson(data) +def base(id,is_upd=0): + "基本配置信息" + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + paths=ar['paths'] + filenames=ar['title']+ar['edition'] + if ar['platform']=='Linux': + if not os.path.exists(paths+filenames+"/bin/conf"): + os.makedirs(paths+filenames+"/bin/conf") + filepath=paths+filenames+"/bin/conf/base.ini" + phpinipath=paths+filenames+"/bin/php.ini" + elif ar['platform']=='Windows': + if not os.path.exists(paths+filenames+"/conf"): + os.makedirs(paths+filenames+"/conf") + filepath=paths+filenames+"/conf/base.ini" + phpinipath=paths+filenames+"/php.ini" + if is_upd: #修改基本配置信息 + #修改php.ini配置 + data=request.get_json() + f = open(phpinipath) + con='' + while True: + line = f.readline() + if not line: + break + elif 'max_execution_time' in line and '=' in line:#最大执行时间 + line="max_execution_time = "+data['text']['max_execution_time']+"\n" + elif 'max_input_time' in line and '=' in line:#最大输入时间 + line="max_input_time = "+data['text']['max_input_time']+"\n" + elif 'memory_limit' in line and '=' in line:#内存限制 + line="memory_limit = "+data['text']['memory_limit']+"M\n" + elif 'file_uploads' == line[0:12] and '=' in line:#是否允许文件上传 + line="file_uploads = "+data['text']['file_uploads']+"\n" + elif 'upload_max_filesize' in line and '=' in line:#上传大小限制 + line="upload_max_filesize = "+data['text']['upload_max_filesize']+"M\n" + elif 'max_file_uploads' in line and '=' in line:#上传数量限制 + line="max_file_uploads = "+data['text']['max_file_uploads']+"\n" + elif 'post_max_size' in line and '=' in line:#上传数量限制 + line="post_max_size = "+data['text']['post_max_size']+"M\n" + elif 'allow_url_fopen' in line and '=' in line: + line="allow_url_fopen = "+data['text']['allow_url_fopen']+"\n" + elif 'allow_url_include' in line and '=' in line: + line="allow_url_include = "+data['text']['allow_url_include']+"\n" + elif 'default_socket_timeout' in line and '=' in line: + line="default_socket_timeout = "+data['text']['default_socket_timeout']+"\n" + con=con+line + f.close() + f= open(phpinipath, "w") + f.write(con) + f.close() + file_set_content(filepath,json_encode(data['text'])) + # print(data['text']) + return successjson() + else: + base=json_decode(file_get_content(filepath)) + if not base: + base='' + data={ + 'base':base, + 'php':ar + } + return successjson(data) +def extenlist(id,is_upd=0): + "php扩展信息列表" + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + lists=sqlite('php_exten',model_intapp_soft_php_exten_path).where('pid',id).select() + data={ + 'extenlist':lists, + 'php':ar + } + return successjson(data) +def log(id): + "待完善" + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + filename=ar['filename'] + paths=ar['paths'] + filenames=ar['title']+ar['edition'] + if ar['platform']=='Linux': + filepath=paths+filenames+"" + elif ar['platform']=='Windows': + filepath=paths+filenames+"" + data={ + 'log':file_get_content(filepath), + 'php':ar + } + return successjson(data) + +def add_php_exten(): + "增加php扩展" + data=request.get_json() + data['addtime']=times() + data['updtime']=times() + sqlite('php_exten',model_intapp_soft_php_exten_path).insert(data) + return successjson() +def del_php_exten(id): + "删除php扩展" + sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',id).delete() + return successjson() + +def installext(id): + is_del=False #是否删除成功 + "安装php扩展和下载扩展" + ar=sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',id).find() + if ar['status']==0: + sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':1,'msg':''}) + Queues.insert(target=__installextqu,args=(ar,),title="安装php-"+ar['title']+"扩展") + elif ar['status']==4: + "卸载扩展" + paths=request.get_json()['paths'] + if get_sysinfo()['uname'][0]=='Linux': + if os.path.exists(paths): + + confile=paths+"bin/php.ini" + f= open(confile, "r") + con='' + while True: + line = f.readline() + if not line: + break + elif str(ar['title']) in line: + line="" + is_del=True + con=con+line + f.close() + f= open(confile, "w") + f.write(con) + f.close() + + # confile=paths+"bin/php.ini" + # f= open(confile, "r") + # con=f.read() + # f.close() + # con=con.replace("extension="+str(ar['title'])+".so\n","") + # f= open(confile, "w") + # f.write(con) + # f.close() + if is_del: + sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':0,'msg':''}) + if 'php7.0' in paths: + os.system("pkill php70-fpm && php70-fpm -c "+paths+"php7.0/etc/php.ini") + elif 'php7.1' in paths: + os.system("pkill php71-fpm && php71-fpm -c "+paths+"php7.1/etc/php.ini") + elif 'php7.2' in paths: + os.system("pkill php72-fpm && php72-fpm -c "+paths+"php7.2/etc/php.ini") + elif 'php7.3' in paths: + os.system("pkill php73-fpm && php73-fpm -c "+paths+"php7.3/etc/php.ini") + elif 'php7.4' in paths: + os.system("pkill php74-fpm && php74-fpm -c "+paths+"php7.4/etc/php.ini") + else: + return errorjson(code=1,msg='卸载失败') + else: + return errorjson(code=1,msg='php文件夹错误') + return successjson() +def get_exten(id): + return successjson(sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',id).find()) +def __installextqu(ar): + "安装php扩展" + sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':3,'msg':''}) + try: + cmd="wget "+config.domain['kcwebfile']+"/"+ar['filename'] + # os.system(cmd) + print(cmd) + pi=subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) + ars=pi.stdout.read().decode() + ars=ars.split("\n") + strs=ars[len(ars)-2] + if 'success' in strs: + sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':4,'msg':''}) + else: + sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':0,'msg':'安装失败'}) + # sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':4,'msg':''}) + except Exception as e: + sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':0,'msg':'安装失败'+str(e)}) \ No newline at end of file diff --git a/app/intapp/controller/soft/redis.py b/app/intapp/controller/soft/redis.py new file mode 100644 index 0000000..df44a4d --- /dev/null +++ b/app/intapp/controller/soft/redis.py @@ -0,0 +1,69 @@ +from .common import * +def conf(id,is_upd=0): + "redis配置文件信息" + is_upd=int(is_upd) + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + paths=ar['paths'] + filenames=ar['title']+ar['edition'] + if ar['platform']=='Linux': + filepath=paths+filenames+"/redis.conf" + else: + return errorjson(code=1,msg="不支持此时平台") + if is_upd: #修改配置 + data=request.get_json() + if not data['text']: + return errorjson(code=1,msg='不允许清空配置文件') + file_set_content(filepath,data['text']) + return successjson() + else: + data=file_get_content(filepath) + # print(filepath) + return successjson(data) +def base(id,is_upd=0): + "redis配置文件信息" + is_upd=int(is_upd) + ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() + paths=ar['paths'] + filenames=ar['title']+ar['edition'] + + if ar['platform']=='Linux': + filepath=paths+filenames+"/redis.conf" + jsonpath=paths+filenames+"/redis.json" + else: + return errorjson(code=1,msg="不支持此时平台") + if is_upd: #修改配置 + data=request.get_json() + f = open(filepath) + con='' + while True: + line = f.readline() + if not line: + break + elif 'bind ' in line and '\n' in line and '#' not in line: + line="bind "+data['bind']+"\n" + elif 'port ' in line and '\n' in line and '#' not in line: + line="port "+data['port']+"\n" + elif 'timeout ' in line and '\n' in line and '#' not in line: + line="timeout "+data['timeout']+"\n" + elif 'maxclients ' in line and '\n' in line: + line="maxclients "+data['maxclients']+"\n" + elif 'databases ' in line and '\n' in line and '#' not in line: + line="databases "+data['databases']+"\n" + elif 'requirepass ' in line and '\n' in line: + if data['requirepass']: + line="requirepass "+data['requirepass']+"\n" + else: + line="# requirepass "+data['requirepass']+"\n" + elif 'maxmemory ' in line and '\n' in line and len(line)<20: + line="maxmemory "+data['maxmemory']+"\n" + con=con+line + f.close() + f= open(filepath, "w") + f.write(con) + f.close() + file_set_content(jsonpath,json_encode(data)) + return successjson() + else: + v=file_get_content(jsonpath) + data=json_decode(v) + return successjson(data) \ No newline at end of file diff --git a/app/intapp/controller/soft/role.txt b/app/intapp/controller/soft/role.txt new file mode 100644 index 0000000..1da7c1d --- /dev/null +++ b/app/intapp/controller/soft/role.txt @@ -0,0 +1,44 @@ +#以下是该插件的路由,index容器会自动把以下路由加入到权限管理中 该文件必须使用utf-8编码 +软件页面,/intapp/soft/index/index +软件信息,/intapp/soft/index/gettitle +软件列表,/intapp/soft/index/softlist +更新软件列表,/intapp/soft/index/updatesoftlist +软件状态描述,/intapp/soft/index/getstatus +安装软件,/intapp/soft/index/insert +启动软件,/intapp/soft/index/start +停止软件,/intapp/soft/index/stop +卸载软件,/intapp/soft/index/uninstall +gitssh公钥,/intapp/soft/index/gitssh +软件设置页面,/intapp/soft/page/soft + +frp服务端内容,/intapp/soft/frp/get_server +frp运行状态,/intapp/soft/frp/run_status +frp重启,/intapp/soft/frp/restart +frp停止,/intapp/soft/frp/stop +修改frp服务端配置,/intapp/soft/frp/upd_server +frp客户端内容,/intapp/soft/frp/get_client +修改frp客户端配置,/intapp/soft/frp/upd_client + +mongodb管理,/intapp/soft/mongodb + +获取mysql配置,/intapp/soft/mysql/get_data +修改mysql配置,/intapp/soft/mysql/upd_my +修改mysql密码,/intapp/soft/mysql/upd_data +备份mysql,/intapp/soft/mysql/backups + +nginx网站管理,/intapp/soft/page/s +修改nginx配置,/intapp/soft/nginx/index +nginx伪静态模板,/intapp/soft/nginx/anphp +nginx网站信息,/intapp/soft/nginx/webdescribesfind +nginx网站列表,/intapp/soft/nginx/weblist +添加更新nginx网站,/intapp/soft/nginx/add_web +删除nginx网站,/intapp/soft/nginx/del_web +获取ssl,/intapp/soft/nginx/getssl +获取伪静态内容,/intapp/soft/nginx/getrewr +获取配置文件,/intapp/soft/nginx/getconfig +证书夹,/intapp/soft/nginx/sslfolde +证书内容,/intapp/soft/nginx/ssltpl + +php管理,/intapp/soft/php + +redis管理,/intapp/soft/redis diff --git a/app/intapp/controller/soft/tpl/index/home.html b/app/intapp/controller/soft/tpl/index/home.html new file mode 100644 index 0000000..cf08d1b --- /dev/null +++ b/app/intapp/controller/soft/tpl/index/home.html @@ -0,0 +1,428 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+
+ + + 搜索 + + + 更新软件列表 + +
+
+ + % if config.app['appmode']=='develop': + + + + % endif + + + + + + + + + + + + + + + + + + +
+
+ + +
+ + + + + + + + + + + + + + + 如:/usr/local/php/ + + + + + + + + + + 注:需要在后端接口上配置wget文件地址 + + + + Linux + Windows + + + + + + +
+ + + diff --git a/app/intapp/controller/soft/tpl/index/web.html b/app/intapp/controller/soft/tpl/index/web.html new file mode 100644 index 0000000..a89e59e --- /dev/null +++ b/app/intapp/controller/soft/tpl/index/web.html @@ -0,0 +1,515 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+
+    + + + 搜索 + 添加网站 + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
域名
端口 + 上传限制:MB
网站名
配置文件模板 + + + + +
备注
网站目录
+
+ + + + + + + +
+ + + + + + + 如:Access-Control-Allow-Origin * + 如:403 /403.html + + +
+ 自定义配置:自定义响应或自定义错误页面 + +
+ +
+
+ + + + + + + + +
+ + + + + + + + + +   + + +
+ nginx负载均衡是一个代理均衡转发器 + +
+ +
+ + 取 消 + 修改添加 + +
+ + +
+
+ +
+
+ 您已配置Let's证书


+ ssl_certificate :{{admin.ssl_certificate}}

+ ssl_certificate_key :{{admin.ssl_certificate_key}}

+ 使用自有证书 +
+
+
+ 密钥(KEY) + +
+
+ 证书(PEM格式) + +
+ 确定 +
+
+
+ + +
+ + + + + +
+ 保存
+ 选择伪静态模板就可以了,修改了记得要保存哦!重启nginx生效 +
+ +
+ + 确定 +
+
+ +
+ + + + + + + +
支持域名有效期
+ + {{item1.domain}}     + + + + {{time_date(item.config.createtime+7776000,true)}} + + + + 使用 + +
+
+
+
+ + + diff --git a/app/intapp/controller/soft/tpl/soft/frp.html b/app/intapp/controller/soft/tpl/soft/frp.html new file mode 100644 index 0000000..c137b73 --- /dev/null +++ b/app/intapp/controller/soft/tpl/soft/frp.html @@ -0,0 +1,250 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+ + + + + 重启 + 停止 + + 保存 + + + + + + +
+ 重启 + 停止 + + + + 这是服端监听的地址 + + + + 这是服端监听的端口 + + + + 这是upd监听的端口 + + + + 这是kcp监听的端口 + + + + 这是http监听的端口 + + + + 这是https监听的端口 + + + + 这是dashboard监听的ip地址 + + + + 这是dashboard监听的端口 + + + + 这是dashboard监听的用户名 + + + + 这是dashboard监听的密码 + + + + 这是frp的验证机制 + + + + 这是frp的验证串的有效时间 + + + + + + + + 日志保持多少天 + + + + + + + + 白名单端口 + + + + 最大值进程数 + + + + + + + + + + + + + + + 保存 + + +
+ +
+ + + 保存 + +
+
+
+
+ + + \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/git.html b/app/intapp/controller/soft/tpl/soft/git.html new file mode 100644 index 0000000..ce87f2d --- /dev/null +++ b/app/intapp/controller/soft/tpl/soft/git.html @@ -0,0 +1,69 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+
+ +
+ 您可以使用root身份执行以下命令生成ssh密钥

+ +
+
+
+ + + \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/kodexplorer.html b/app/intapp/controller/soft/tpl/soft/kodexplorer.html new file mode 100644 index 0000000..6f38ff4 --- /dev/null +++ b/app/intapp/controller/soft/tpl/soft/kodexplorer.html @@ -0,0 +1,88 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + 添加 + +
+
+
+ + + + \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/mongodb.html b/app/intapp/controller/soft/tpl/soft/mongodb.html new file mode 100644 index 0000000..417da13 --- /dev/null +++ b/app/intapp/controller/soft/tpl/soft/mongodb.html @@ -0,0 +1,436 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +

可以在终端中执行以下命令创建可以 +

+ WORK_DIR=/data/mongodb
+ mkdir -p $WORK_DIR/key/
+ cd $WORK_DIR/key/
+ openssl rand -base64 756 > mongo.key
+ chmod 600 mongo.key
+
+

+ 保存 +
+
+ +
+ config服务 (注:这是一个config服务) + + + + + + +
+ 通常生产环境每台机器应该只有一个,您可以在其他机器上开启config服务后手动添加到副本集中
+ +
+ 运行中 + 停止服务 + 重启服务 +
+
+ 已停止 + 启动服务 +
+
+ 待初始化 + 初始化 +
+

+
+ 副本集初始化(如果需要,生产环境应该是内网ip而不是127.0.0.1)
+
+ +
+增加副本集示例 +
+mongo --port {{data.configs.server[0]['port']}}
+use admin
+rs.add({_id:1,host:'{{data.get_local_ip}}:27002',priority:2})#增加主机 priority:优先级
+
+删除副本集示例 +
+mongo --port {{data.configs.server[0]['port']}}
+use admin
+rs.remove('{{data.get_local_ip}}:27002')
+
+
+ +
+
+ +
+ configdb: +
示例:configdb = configs/192.168.1.101:27001,192.168.1.102:27001,192.168.1.103:27001,则无法扩展外部服务器
+ 上述ip和端口是已经启动的配置服务,可以是其他机器上的mongodb配置服务 +
+ 路由服务 (注:这是一个路由服务) + + + + + + +
+ +
+
+ 运行中 + 停止服务 + 重启服务 +
+
+ 已停止 + 启动服务 +
+
+ 待初始化 + 初始化 +
+
+
+ 初始化用户
+
+ +
+ 在路由中添加分片,如下示例
+
+mongo --port {{data.mongos.server[0]['port']}}
+use admin
+db.auth('admin','admin')
+sh.addShard("shard1/192.168.1.101:29001,192.168.1.102:29001") #shard1是分片集群id
+sh.status()
+
+
+
+
+ +
+
+ 分片服务名{{indexs+1}}: + + + + + + + +
+ 通常生产环境每台机器应该只有一个,您可以在其他机器上开启分片服务后手动添加到副本集中
+ +
+ 运行中 + 停止服务 + 重启服务 +
+
+ 已停止 + 启动服务 +
+
+ 待初始化 + 初始化 +
+

+
+ 副本集初始化(生产环境应该是内网ip而不是127.0.0.1)
+ +
+
+ +
+
+
+ + + +
+ + + + + + + + + + + + + +
绑定ip端口服务目录
+ + 运行中 + 停止 + + + 已停止 + 启动 + + +
+
+ + 保存 +
+ +
+
+ + + \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/mysql.html b/app/intapp/controller/soft/tpl/soft/mysql.html new file mode 100644 index 0000000..ebeb98f --- /dev/null +++ b/app/intapp/controller/soft/tpl/soft/mysql.html @@ -0,0 +1,106 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + 建议与mysql安装目录分开 + + 保存 + + + +
+ + 保存 +
+
+
+
+
+ + + \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/nginx.html b/app/intapp/controller/soft/tpl/soft/nginx.html new file mode 100644 index 0000000..8956ac7 --- /dev/null +++ b/app/intapp/controller/soft/tpl/soft/nginx.html @@ -0,0 +1,113 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+ + + + + + 保存 + 该配置文件只对该网站有效,修改后重启nginx生效
+
+ +
+ +
+ + + + \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/php.html b/app/intapp/controller/soft/tpl/soft/php.html new file mode 100644 index 0000000..f281a40 --- /dev/null +++ b/app/intapp/controller/soft/tpl/soft/php.html @@ -0,0 +1,331 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + MB + + + 单个请求上传的文件的最大数量 + + + 秒 + + + 秒 + + + MB + + + MB + + + + + + 是否允许将url(如http://或 ftp://)作为文件处理。 + + + + + + 是否允许include/require以文件形式打开url(如http://或 ftp://)。 + + + + 基于套接字的流的默认超时(秒) + + + 保存 +
+
+ +
+ + + + + + + + + + 允许创建的最大子进程数 + + + + 起始进程数(服务启动后初始进程数量) + + + + 最小空闲进程数(清理空闲进程后的保留数量) + + + + 最大空闲进程数(当空闲进程达到此值时清理) + + + 保存 +
+
+ +
+ % if config.app['appmode']=='develop': + + % endif + + + + + + + + +
名称说明状态操作
{{item.title}}{{item.describes}} + % if config.app['appmode']=='develop': + {{item.filename}} + % endif + + + + + + 安装 + + + 等待下载 + + + 正在下载 + + + 正在安装 + + + 卸载 + + + 正在卸载... + + % if config.app['appmode']=='develop': + 删除 + % endif +
+
+
+ + + + + 保存 + 该配置文件只对{{data.php.title}}有效,修改后重启{{data.php.title}}生效
+
+ + + + 保存 + 该配置文件只对{{data.php.title}}有效,修改后重启{{data.php.title}}生效
+
+
+ + + + + + + + + + + + + + + + + + + 添加 + +
+ + + \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/phpmyadmin.html b/app/intapp/controller/soft/tpl/soft/phpmyadmin.html new file mode 100644 index 0000000..053916a --- /dev/null +++ b/app/intapp/controller/soft/tpl/soft/phpmyadmin.html @@ -0,0 +1,90 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + 添加 + +
+
+
+ + + + \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/redis.html b/app/intapp/controller/soft/tpl/soft/redis.html new file mode 100644 index 0000000..64eac89 --- /dev/null +++ b/app/intapp/controller/soft/tpl/soft/redis.html @@ -0,0 +1,127 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + 绑定IP + + + 端口 + + + 空闲连接超时时间,0表示不断开 + + + 最大连接数 + + + 数据库数量 + + + redis密码,留空代表没有设置密码 + + + MB,最大使用内存,0表示不限制 + + + 保存 +
+
+ + + + + 保存 + 修改后重启redis生效
+
+
+
+ + + \ No newline at end of file -- Gitee From 6d8f947e3a8bac1e2df8cbc79735e72c9998a047 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 04:12:01 +0800 Subject: [PATCH 038/202] kun --- app/intapp/controller/__init__.py | 3 +- app/intapp/controller/soft/__init__.py | 8 - app/intapp/controller/soft/common/SOFT.py | 213 -------- app/intapp/controller/soft/common/__init__.py | 2 - app/intapp/controller/soft/common/autoload.py | 10 - .../soft/common/file/sqlite/.gitignore | 1 - .../soft/common/file/sqlite/php_exten | Bin 24576 -> 0 bytes app/intapp/controller/soft/common/model.py | 85 --- app/intapp/controller/soft/frp.py | 133 ----- app/intapp/controller/soft/index.py | 91 ---- app/intapp/controller/soft/install.txt | 1 - app/intapp/controller/soft/mongodb.py | 247 --------- app/intapp/controller/soft/mysql.py | 254 --------- app/intapp/controller/soft/nginx.py | 360 ------------ app/intapp/controller/soft/page.py | 13 - app/intapp/controller/soft/php.py | 266 --------- app/intapp/controller/soft/redis.py | 69 --- app/intapp/controller/soft/role.txt | 44 -- .../controller/soft/tpl/index/home.html | 428 --------------- app/intapp/controller/soft/tpl/index/web.html | 515 ------------------ app/intapp/controller/soft/tpl/soft/frp.html | 250 --------- app/intapp/controller/soft/tpl/soft/git.html | 69 --- .../controller/soft/tpl/soft/kodexplorer.html | 88 --- .../controller/soft/tpl/soft/mongodb.html | 436 --------------- .../controller/soft/tpl/soft/mysql.html | 106 ---- .../controller/soft/tpl/soft/nginx.html | 113 ---- app/intapp/controller/soft/tpl/soft/php.html | 331 ----------- .../controller/soft/tpl/soft/phpmyadmin.html | 90 --- .../controller/soft/tpl/soft/redis.html | 127 ----- 29 files changed, 1 insertion(+), 4352 deletions(-) delete mode 100644 app/intapp/controller/soft/__init__.py delete mode 100644 app/intapp/controller/soft/common/SOFT.py delete mode 100644 app/intapp/controller/soft/common/__init__.py delete mode 100644 app/intapp/controller/soft/common/autoload.py delete mode 100644 app/intapp/controller/soft/common/file/sqlite/.gitignore delete mode 100644 app/intapp/controller/soft/common/file/sqlite/php_exten delete mode 100644 app/intapp/controller/soft/common/model.py delete mode 100644 app/intapp/controller/soft/frp.py delete mode 100644 app/intapp/controller/soft/index.py delete mode 100644 app/intapp/controller/soft/install.txt delete mode 100644 app/intapp/controller/soft/mongodb.py delete mode 100644 app/intapp/controller/soft/mysql.py delete mode 100644 app/intapp/controller/soft/nginx.py delete mode 100644 app/intapp/controller/soft/page.py delete mode 100644 app/intapp/controller/soft/php.py delete mode 100644 app/intapp/controller/soft/redis.py delete mode 100644 app/intapp/controller/soft/role.txt delete mode 100644 app/intapp/controller/soft/tpl/index/home.html delete mode 100644 app/intapp/controller/soft/tpl/index/web.html delete mode 100644 app/intapp/controller/soft/tpl/soft/frp.html delete mode 100644 app/intapp/controller/soft/tpl/soft/git.html delete mode 100644 app/intapp/controller/soft/tpl/soft/kodexplorer.html delete mode 100644 app/intapp/controller/soft/tpl/soft/mongodb.html delete mode 100644 app/intapp/controller/soft/tpl/soft/mysql.html delete mode 100644 app/intapp/controller/soft/tpl/soft/nginx.html delete mode 100644 app/intapp/controller/soft/tpl/soft/php.html delete mode 100644 app/intapp/controller/soft/tpl/soft/phpmyadmin.html delete mode 100644 app/intapp/controller/soft/tpl/soft/redis.html diff --git a/app/intapp/controller/__init__.py b/app/intapp/controller/__init__.py index f4dbb41..6a03892 100644 --- a/app/intapp/controller/__init__.py +++ b/app/intapp/controller/__init__.py @@ -1,3 +1,2 @@ -from . import index -from . import soft \ No newline at end of file +from . import index \ No newline at end of file diff --git a/app/intapp/controller/soft/__init__.py b/app/intapp/controller/soft/__init__.py deleted file mode 100644 index f7a8da3..0000000 --- a/app/intapp/controller/soft/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from . import index -from . import page -from . import nginx -from . import mysql -from . import redis -from . import mongodb -from . import frp -from . import php \ No newline at end of file diff --git a/app/intapp/controller/soft/common/SOFT.py b/app/intapp/controller/soft/common/SOFT.py deleted file mode 100644 index 1ac9add..0000000 --- a/app/intapp/controller/soft/common/SOFT.py +++ /dev/null @@ -1,213 +0,0 @@ -# -*- coding: utf-8 -*- -from .model import * -class SOFT: - def softlist(kw,pagenow,pagesize): - "软件列表" - if config.app['appmode']=='develop': - where="1=1" - else: - where="platform='"+get_sysinfo()['uname'][0]+"'" - if kw: - where+=" and title LIKE '%"+kw+"%' or describes LIKE '%"+kw+"%'" - lists=sqlite("soft",model_intapp_soft_path).where(where).page(pagenow,pagesize).select() - if len(lists) < 1: - SOFT.updatesoftlist() - lists=sqlite("soft",model_intapp_soft_path).where(where).page(pagenow,pagesize).select() - if 'Linux' in get_sysinfo()['platform']: - i=0 - for k in lists: - if k['status'] == 0 and k['platform']=='Linux': #检查软件是否已经安装 - if (os.path.exists(k['paths']+k['title']+k['edition'])) : - lists[i]['status']=4 - sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':lists[i]['status']}) - if (k['status'] == 10 or k['status'] == 4) and k['platform']=='Linux': #检查软件是否在运行中 - if 'nginx' in k['title'] : - if not get_process_id('nginx'): - if k['status'] == 10: - lists[i]['status']=4 - sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止 - else: - if k['status'] == 4: - lists[i]['status']=10 - sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中 - elif 'redis' in k['title']: - if not get_process_id('redis'): - if k['status'] == 10: - lists[i]['status']=4 - sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止 - else: - if k['status'] == 4: - lists[i]['status']=10 - sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中 - elif 'mysql' in k['title']: - if not get_process_id('mysql'): - if k['status'] == 10: - lists[i]['status']=4 - sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止 - else: - if k['status'] == 4: - lists[i]['status']=10 - sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中 - elif 'php5' in k['title']+k['edition'] or 'php7' in k['title']+k['edition']: - title=k['title']+k['edition'] - # print("php",title,title.replace(".", "")+"-fpm") - if not get_process_id(title): - if k['status'] == 10: - lists[i]['status']=4 - sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止 - else: - if k['status'] == 4: - lists[i]['status']=10 - sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中 - i+=1 - count=sqlite("soft",model_intapp_soft_path).where(where).count() - data=return_list(lists,count,pagenow,pagesize) - return data - def updatesoftlist(): - "更新软件列表" - http=Http() - sqlite("soft",model_intapp_soft_path).where("1=1").delete() - def openkcweb(pagenow=1,pagesize=20): - http.openurl(config.domain['kcwebapi']+"/pub/soft_list","POST",{ - "pagenow":pagenow,"pagesize":pagesize - }) - res=json_decode(http.get_text) - lists=[] - if res['code']==0: - for k in res['data']['lists']: - k['status']=0 - k['msg']='' - k['addtime']=times() - lists.append(k) - sqlite("soft",model_intapp_soft_path).insert(lists) - if pagenow log 2>&1 &",name="redis服务") - return True - elif 'mysql' == arr['title']: - if os.path.isfile(arr['paths']+arr['title']+arr['edition']+"/support-files/mysql.server"): - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":"安装成功"}) - system_start.insert_Boot_up("mysqld start",name="mysql服务") - return True - elif 'frp' == arr['title']: - if os.path.isfile(arr['paths']+arr['title']+arr['edition']+"/frps") and os.path.isfile(arr['paths']+arr['title']+arr['edition']+"/frpc"): - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":"安装成功"}) - return True - else: - if os.path.exists(arr['paths']+arr['title']+arr['edition']): - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":"安装成功"}) - return True - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"安装失败,目录不存在"+arr['paths']+arr['title']+arr['edition']}) - else: - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"安装失败"}) - else: - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"下载失败"}) - except Exception as e: - sqlite('soft',model_intapp_soft_path).where('id',id).update({'status':0,'msg':'安装失败'+str(e)}) - def start(id): - "启动软件服务" - arr=sqlite("soft",model_intapp_soft_path).where("id",id).find() - if arr['platform']=='Linux': ###############################LINUX - if 'nginx' == arr['title']: - os.system("nginx") - elif 'php' == arr['title']: - titleedition=arr['title']+arr['edition'] - fpmname=titleedition.replace(".", "")+"-fpm" - os.system(fpmname+" -c "+arr['paths']+arr['title']+arr['edition']+"/bin/php.ini -R") - # print("php启动",fpmname+" -c "+arr['paths']+arr['title']+arr['edition']+"/bin/php.ini -R") - elif 'redis' == arr['title']: - os.system("nohup redis-server "+arr['paths']+arr['title']+arr['edition']+"/redis.conf > log 2>&1 &") - elif 'mysql' == arr['title']: - os.system("mysqld start") - else: - os.system("cd "+arr['paths']+arr['title']+arr['edition']+" && bash start.sh") - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":10,"msg":"运行中"}) - else: - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":""}) - def stop(id): - arr=sqlite("soft",model_intapp_soft_path).where("id",id).find() - if arr['platform']=='Linux': ###############################LINUX - if 'nginx' == arr['title']: - os.system("pkill nginx") - elif 'php' == arr['title']: - titleedition=arr['title']+arr['edition'] - fpmname=titleedition.replace(".", "")+"-fpm" - os.system("pkill -9 "+fpmname) - elif 'redis' == arr['title']: - os.system("pkill redis") - elif 'mysql' == arr['title']: - os.system("mysqld stop") - elif 'mongo' == arr['title']: - os.system("pkill mongo") - else: - os.system("cd "+arr['paths']+arr['title']+arr['edition']+" && bash stop.sh") - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":""}) - def uninstall(id): - try: - arr=sqlite("soft",model_intapp_soft_path).where("id",id).find() - if arr['platform']=='Linux': ###############################LINUX - os.system("rm -rf "+arr['paths']+arr['title']+arr['edition']) - startpath="/usr/bin/" - if 'nginx' == arr['title']: - system_start.del_Boot_up("nginx") - os.system("pkill -9 nginx") - model_intapp_menu.delete(title="网站管理",sort=9000) - os.system("rm -rf "+startpath+"nginx") - elif 'redis' == arr['title']: - system_start.del_Boot_up("nohup redis-server "+arr['paths']+arr['title']+arr['edition']+"/redis.conf > log 2>&1 &") - os.system("rm -rf "+startpath+"redis-server") - elif 'php' == arr['title']: - titleedition=arr['title']+arr['edition'] - fpmname=titleedition.replace(".", "")+"-fpm" - system_start.del_Boot_up(fpmname+" -c "+arr['paths']+arr['title']+arr['edition']+"/bin/php.ini -R") - - - os.system("rm -rf "+startpath+fpmname) - elif 'mysql' == arr['title']: - system_start.del_Boot_up("mysqld start") - os.system("rm -rf "+startpath+"mysqld && rm -rf "+startpath+"mysql && rm -rf /etc/my.cnf") - elif 'mongodb' == arr['title']: - system_start.del_Boot_up("mongo",True) - os.system("pkill -9 mongo") - os.system("rm -rf /data/mongodb") - elif 'frp' == arr['title']: - system_start.del_Boot_up("frps",True) - system_start.del_Boot_up("frpc",True) - os.system("pkill -9 frps") - os.system("pkill -9 frpc") - else: - if os.path.exists(arr['paths']+arr['title']+arr['edition']): - sqlite('soft',model_intapp_soft_path).where('id',id).update({'status':4,'msg':'卸载失败'}) - return - except Exception as e: - sqlite('soft',model_intapp_soft_path).where('id',id).update({'status':4,'msg':'卸载失败'+str(e)}) - else: - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"已卸载"}) \ No newline at end of file diff --git a/app/intapp/controller/soft/common/__init__.py b/app/intapp/controller/soft/common/__init__.py deleted file mode 100644 index 8879824..0000000 --- a/app/intapp/controller/soft/common/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from .SOFT import * \ No newline at end of file diff --git a/app/intapp/controller/soft/common/autoload.py b/app/intapp/controller/soft/common/autoload.py deleted file mode 100644 index c4bee80..0000000 --- a/app/intapp/controller/soft/common/autoload.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -from app.intapp.common import * -import subprocess -def get_process_id(name): - try: - child = subprocess.Popen(['pgrep', '-f', name],stdout=subprocess.PIPE, shell=False) - response = child.communicate()[0] - return [int(pid) for pid in response.split()] - except: - return [] diff --git a/app/intapp/controller/soft/common/file/sqlite/.gitignore b/app/intapp/controller/soft/common/file/sqlite/.gitignore deleted file mode 100644 index f3c316e..0000000 --- a/app/intapp/controller/soft/common/file/sqlite/.gitignore +++ /dev/null @@ -1 +0,0 @@ -soft \ No newline at end of file diff --git a/app/intapp/controller/soft/common/file/sqlite/php_exten b/app/intapp/controller/soft/common/file/sqlite/php_exten deleted file mode 100644 index 643a9415b601d5c3a803687d93aa38c01a1857ef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24576 zcmeHPdu&tJ8TXAH=i0t@n$eJTAnll zT)4ND$tfr6>l^LFH}ea;&HVa?CfizDBj2#0iEr3kSI2K` zTwh<)xP^b#wuP_R+_YhR0~}p%YiKIv1LN#p%7?rmpNoI4rg6=>n#Khcl~oJ*THDh# zo9mkR`SauLmh#Q6ptH@p%@vIATe)=E1p5X9&)9;+v{^-$CGHICAdAlS4DZ{ zk_n(3&CMY%G?*wvDc>F#|33?}Vbo>ieu-mGpZl-eFU@`C2JR@AWAYep84C?>81mTt z?4vpF<<#o`oc&35t!}UOu0Eh$nl+GB!klBQn%`=+j5~1Myh+2%Dq)G)tkW5rw>dVh z+bCQ;6FJ=TR&= z^0EpZnzP4-K1B-@15Od(6d;b%0h%^D+A;~IvzGqz>i=K1%+Fg-T zy^&*Ag@Kdz(;Bo~BsQuR`x_f2wSh|*jc{{-&m)9kcO#$R4!_^$5{C9hdb&T|Lxlbt zu{V#xo7-2;ME1NBdwDoI{7Q82{OvtwN5gLlL#HAqyZFko%Chq4p@Wh0@A2ag0I5|q zqp>YyL7#QPr$Ux;*d-+uSHaQO20fY@RAU^QyO z<~a0jfZk13{D1>&Qq7Wl05|vpPKVRug09BG2ZY}JJd6lFw(l%-^Y&Z&qC=-+*It3s zBlNr$JG?jg27!|&?7b`;>=in%j}BasPiJ3G5NCGWDR}`JyWnOc=sA#;nLaYKsb8&2y`VDJ_m0iUGE47Z`|*aO;TZz zfIT)CLnGRJIN^C-mY8s?Zf}k=laPQPjBer5zUYbl!nqM)_$?fG;v5YVNP1&$dowV& zg$6!?#cA5}2$0E#={gt5INRICgvvn2u{}5=OVB*C)JU$KUUx#r(;5TV9`tJf&HX(< zQe2%Oqpq%8a&?361J3(_Jit+0ok4L+ne3I)CZJtHb3df+Sw>x5IWM}p!IOY`VVb-g(y^m;n1PMrvq2Nf0X#%9vzAe!WJ`o6Nq`o3~!1Cru%*bMp{1QKtr`aT1k&jLEY zQG5=o_=kiulGgcG+61(Z(cD^f&obz9#1n?MSA8F#bz}jKGPAOiKeGZnz+OiqECbkz zyJM%^-7ST0W7$u@FWqd+%`>@oHSj}UQ~|00Re&l$6`%@G1*ig40jdC1fGR*0pbGrI zC}3u^#S8?+rMij+v)-e5So<}j>$m*V@~VYb=l``|r;-2Hdvu@215`BspKN6V&HrOn zfjSdU^Z%*G`Ind7lmFLym`xD(#QZ;5At!hkv5aA|6Fj=K!o=}11}Vd%pY|B47|uNb z;oK86|37}6RyjYG|2GzD+Gzg&flJ+J{y*tbw+UuRn*WD_NE~;`R=LIV|GDj&!Efoe zUYh^Ee+@0BLTUa#y-Gkaoh;WX()@pFwcM!TcQF4Cv+9uE(bGBbvYQ)iI;3;` zT;5?)>a7y$k1|^kmL7S9qCGb9A2iPrahOX5&!$Y4gyFD~O2S4WfE00C0ZAzdGi9(O z41vUwun{QG8u>U-2{=kgm`Rzw6HZCW_xj?sE3e`Kw2#o-73!X4up|t@#E9F-hk)}T zF_Z&Pfu9jq+?Z0U%bH;LBzYeKv%^Rq8sQcL7o`r_G);BLNat;|U1h+g&?Zk;NmR?- zM}{Pq+aR_Rja1EtS)h=}g~-O4T8NA*)8b*O;Z63~@FveZkWDEFHIC!t(zs44WFI$N z3rMi8=W#qk^12>lYCbM4HgOj>TmghC$eg*7i<4JqWyHm$MNsx|!^J?am}q|ldMV3d zj1TJJ(jtNmZrF@QsvnaaoVX!7;wW}FlyK2rcYG!3WugSGp{$P31+-qLP-QpfLbs6s% z?S{V_Rd`+0p?_V4uPQ@quuhfxKn0#t$Tjsh*u;LR8WH}T;VCV#-y8Vvd% z1fYHb%6;yT>G>GP|N4R47`2&e?U}>TrsA=7v+2jD=HfLL}&>ldx++Hf7aWFnlcnf=O9|gkAaQiQMsw`s0h6S ZjZ{6U_66{LZ>IW!$}wLMZUpL${{^4#H% "+dar+"/log/frpslog 2>&1 &" - os.system("pkill -9 frps") - system_start.del_Boot_up(cmd) - time.sleep(1) - os.system(cmd) - time.sleep(1) - if not get_process_id('frps'): - return errorjson(msg="启动失败,请检查配置") - system_start.insert_Boot_up(cmd=cmd,name="frps服务端") - elif types=='frpc': - cmd="cd "+dar +" && nohup ./frpc -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &" - os.system("pkill frpc") - system_start.del_Boot_up(cmd) - time.sleep(1) - os.system(cmd) - time.sleep(1) - if not get_process_id('frpc'): - return errorjson(msg="启动失败,请检查配置") - system_start.insert_Boot_up(cmd=cmd,name="frpc客户端") - return successjson() -def stop(types='all'): - "停止" - if types=='frps': - system_start.del_Boot_up("cd "+dar +" && nohup ./frps -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &") - os.system("pkill -9 frps") - elif types=='frpc': - system_start.del_Boot_up("cd "+dar +" && nohup ./frpc -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &") - os.system("pkill -9 frpc") - else: - system_start.del_Boot_up("cd "+dar +" && nohup ./frps -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &") - system_start.del_Boot_up("cd "+dar +" && nohup ./frpc -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &") - os.system("pkill -9 frps") - os.system("pkill -9 frpc") - return successjson() -def upd_server(types='ini'): - server=request.get_json() - if types=='ini': - file_set_content(dar+"/frps_full.ini",server['conf']) - elif types=='base': - base=server['base'] - f = open(dar+"/frps_full.ini") - con='' - while True: - line = f.readline() - if not line: - break - elif 'bind_addr = ' in line: - line="bind_addr = "+base['bind_addr']+"\n" - elif 'bind_port = ' in line: - line="bind_port = "+base['bind_port']+"\n" - elif 'bind_udp_port = ' in line: - line="bind_udp_port = "+base['bind_udp_port']+"\n" - elif 'kcp_bind_port = ' in line: - line="kcp_bind_port = "+base['kcp_bind_port']+"\n" - elif 'vhost_http_port = ' in line: - line="vhost_http_port = "+base['vhost_http_port']+"\n" - elif 'vhost_https_port = ' in line: - line="vhost_https_port = "+base['vhost_https_port']+"\n" - elif 'dashboard_addr = ' in line: - line="dashboard_addr = "+base['dashboard_addr']+"\n" - elif 'dashboard_port = ' in line: - line="dashboard_port = "+base['dashboard_port']+"\n" - elif 'dashboard_user = ' in line: - line="dashboard_user = "+base['dashboard_user']+"\n" - elif 'dashboard_pwd = ' in line: - line="dashboard_pwd = "+base['dashboard_pwd']+"\n" - elif 'log_level = ' in line: - line="log_level = "+base['log_level']+"\n" - elif 'log_max_days = ' in line: - line="log_max_days = "+base['log_max_days']+"\n" - elif 'disable_log_color = ' in line: - line="disable_log_color = "+base['disable_log_color']+"\n" - elif 'token = ' in line: - line="token = "+base['token']+"\n" - elif 'allow_ports = ' in line: - line="allow_ports = "+base['allow_ports']+"\n" - elif 'max_pool_count = ' in line: - line="max_pool_count = "+base['max_pool_count']+"\n" - elif 'max_ports_per_client = ' in line: - line="max_ports_per_client = "+base['max_ports_per_client']+"\n" - elif 'subdomain_host = ' in line: - line="subdomain_host = "+base['subdomain_host']+"\n" - elif 'tcp_mux = ' in line: - line="tcp_mux = "+base['tcp_mux']+"\n" - con=con+line - f.close() - file_set_content(dar+"/frps_full.ini",con) - file_set_content(dar+"/frps_full.conf",json_encode(base)) - os.system("pkill frps") - time.sleep(1) - os.system("cd "+dar +" && ./frps -c frps_full.ini &") - time.sleep(1) - if not get_process_id('frps'): - return errorjson(msg="启动失败,请检查配置") - return successjson() -def get_client(): - client={ - 'conf':file_get_content(dar+"/frpc.ini"), - 'base':json_decode(file_get_content(dar+"/frpc.conf")) - } - return successjson(client) -def upd_client(type='ini'): - server=request.get_json() - file_set_content(dar+"/frpc.ini",server['conf']) - os.system("pkill frpc") - time.sleep(1) - os.system("cd "+dar +" && ./frpc -c frpc.ini &") - time.sleep(1) - if not get_process_id('frpc'): - return errorjson(code=1,msg="启动失败,请检查配置") - return successjson() \ No newline at end of file diff --git a/app/intapp/controller/soft/index.py b/app/intapp/controller/soft/index.py deleted file mode 100644 index 54b9ced..0000000 --- a/app/intapp/controller/soft/index.py +++ /dev/null @@ -1,91 +0,0 @@ -from .common import * -def index(): - return response.tpl('index/home') -def gettitle(title,edition): - "获取软件信息" - return successjson(sqlite('soft',model_intapp_soft_path).where("title='"+title+"' and edition='"+edition+"' and platform='"+get_sysinfo()['uname'][0]+"' and status >=4").find()) -def softlist(): - kw=request.args.get("kw") - pagenow=int(request.args.get("pagenow")) - pagesize=int(request.args.get("pagesize")) - return successjson(SOFT.softlist(kw,pagenow,pagesize)) -def updatesoftlist(): - "更新软件列表" - SOFT.updatesoftlist() - return successjson() -def getstatus(id): - "获取软件状态和描述" - return successjson(sqlite("soft",model_intapp_soft_path).field("status,msg").where("id",id).find()) -def insert(id): - "安装软件" - title=sqlite('soft',model_intapp_soft_path).where("id",id).field("title").find()['title'] - if 'nginx' == title: - ass=sqlite('soft',model_intapp_soft_path).where([('title','eq','nginx'),'and',('status','gt',0)]).find() - if ass: - return errorjson(msg="您已安装其他nginx版本,卸载其他nginx版本后可安装此版本") - if 'kodexplorer' in title or 'phpmyadmin' in title: - if not sqlite('soft',model_intapp_soft_path).where([('title','like','%php%'),'and',('status','egt','4')]).count() or not sqlite('soft',model_intapp_soft_path).where([('title','like','%nginx%'),'and',('status','egt','4')]).count(): - return errorjson(msg="先安装nginx和php") - if 'phpmyadmin' in title: - if not sqlite('soft',model_intapp_soft_path).where([('title','like','%mysql%'),'and',('status','egt','4')]).count() or not sqlite('soft',model_intapp_soft_path).where([('title','like','%nginx%'),'and',('status','egt','4')]).count(): - return errorjson(msg="先安装mysql") - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":1,"msg":"安装中"}) - Queues.insert(target=SOFT.insert,args=(id,),title="安装软件:"+title) - return successjson() -def start(id): - "启动软件" - SOFT.start(id) - return successjson() -def stop(id): - "停止软件" - SOFT.stop(id) - return successjson() -def restartnginx(): - """平滑重启nginx""" - os.system("nginx -s reload") - return successjson() - -def uninstall(id): - "卸载软件" - # title=request.args.get("title") - title=sqlite('soft',model_intapp_soft_path).where("id",id).field("title").find()['title'] - if 'nginx' == title: - sqlite("web",model_intapp_soft_path).where("1=1").update({"status":0}) - sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":5,"msg":"卸载中"}) - Queues.insert(target=SOFT.uninstall,args=(id,),title="卸载软件:"+title) - return successjson() - - -def gitssh(): - 'gitssh公钥' - try: - data=file_get_content("/root/.ssh/id_rsa.pub") - except: - data='' - return successjson(data) - - - -def add(): - "添加内容" - try: - data=request.get_json() - data.update(updtime=times(),addtime=times()) - # print(data) - sqlite('software',config.sqlitesoftware).insert(data) - except: - return errorjson(msg="失败") - else: - return successjson() -def update(id=0): - "更新内容" - data=request.get_json() - if not id: - id=data['id'] - try: - data.pop('updtime') - data.pop('addtime') - except:pass - else: - sqlite('software',config.sqlitesoftware).where("id",id).update(data) - return successjson() \ No newline at end of file diff --git a/app/intapp/controller/soft/install.txt b/app/intapp/controller/soft/install.txt deleted file mode 100644 index bd02041..0000000 --- a/app/intapp/controller/soft/install.txt +++ /dev/null @@ -1 +0,0 @@ -oss2==2.2.0 \ No newline at end of file diff --git a/app/intapp/controller/soft/mongodb.py b/app/intapp/controller/soft/mongodb.py deleted file mode 100644 index d444226..0000000 --- a/app/intapp/controller/soft/mongodb.py +++ /dev/null @@ -1,247 +0,0 @@ -from .common import * -import base64 -WORK_DIR="/data/mongodb" -# if not os.path.exists(WORK_DIR): -# os.system("mkdir -p "+WORK_DIR) -def get_config(id): - '获取mongodb页面配置' - try: - data=json_decode(file_get_content(WORK_DIR+"/config.conf")) - except: - data={} - try: - key=file_get_content(WORK_DIR+"/key/mongo.key") - except: - key="" - data['key']=key - data['get_local_ip']=get_local_ip() - data['WORK_DIR']=WORK_DIR - try: - data['configlist']=json_decode(file_get_content(WORK_DIR+"/serverconfig.conf")) - except: - data['configlist']={} - return successjson(data) -def upd_config(id): - '修改mongodb页面配置' - data=request.get_json() - os.system("mkdir -p "+WORK_DIR+"/key") - f=open(WORK_DIR+"/key/mongo.key","w") - f.write(data['key']) - f.close() - os.system("chmod 600 "+WORK_DIR+"/key/mongo.key") - data['key']='' - file_set_content(WORK_DIR+"/config.conf",json_encode(data)) - return successjson() - -def start_config(types='restart'): - '启动/停止config服务' - data=request.get_json() - data['key']='' - os.system("mkdir -p "+WORK_DIR+"/conf") - f=open(WORK_DIR+"/conf/config.conf","w") - f.write("logappend=true\n"+ - "fork=true\n"+ - "maxConns=5000\n"+ - "replSet=configs\n"+ - "keyFile="+WORK_DIR+"/key/mongo.key\n"+ - "configsvr=true") - f.close() - os.system("chmod 777 "+WORK_DIR+"/conf/config.conf") - # os.system("chmod 600 "+WORK_DIR+"/key/mongo.key") - i=1 - for k in data['configs']['server']: - os.system("mkdir -p "+WORK_DIR+"/config"+str(i)+"/data") - i+=1 - if types=='restart' or types=='stop': #停止服务 - i=1 - for k in data['configs']['server']: - pid=file_get_content(WORK_DIR+"/config"+str(i)+"/db.pid") - os.system("kill -9 "+str(pid)) - time.sleep(0.1) - i+=1 - data['configs']['serverstatus']=0 - if types=='restart' or types=='start': #启动服务 - i=1 - for k in data['configs']['server']: - startstatus=False - cmd="mongod --bind_ip "+str(k['ip'])+" --port "+str(k['port'])+" -f "+WORK_DIR+"/conf/config.conf --dbpath "+WORK_DIR+"/config"+str(i)+"/data --logpath "+WORK_DIR+"/config"+str(i)+"/log.log --pidfilepath "+WORK_DIR+"/config"+str(i)+"/db.pid" - result=os.popen(cmd) - res = result.read() - for line in res.splitlines(): - print("line",line) - if 'process started successfully' in line: - startstatus=True - break - if not startstatus: - return errorjson(code=1,msg="启动失败") - - i+=1 - data['configs']['serverstatus']=1 - file_set_content(WORK_DIR+"/config.conf",json_encode(data)) - return successjson() -def start_mongos(types='restart'): - '启动/停止路由服务' - data=request.get_json() - data['key']='' - # for k in data - #创建配置文件 - os.system("mkdir -p "+WORK_DIR+"/conf && mkdir -p "+WORK_DIR+"/mongos") - f=open(WORK_DIR+"/conf/mongos.conf","w") - f.write("logappend = true\n"+ - "fork=true\n"+ - data['mongos']['configdb']+" #这里必须是公共网ip或内网ip,千万不能是127.0.0.1\n" - "keyFile="+WORK_DIR+"/key/mongo.key\n"+ - "maxConns=20000 #最大连接数") - f.close() - os.system("chmod 777 "+WORK_DIR+"/conf/mongos.conf") - os.system("mkdir -p "+WORK_DIR+"/mongos") - if types=='restart' or types=='stop': #停止服务 - i=1 - for k in data['mongos']['server']: - pid=file_get_content(WORK_DIR+"/mongos/db"+str(i)+".pid") - os.system("kill -9 "+str(pid)) - time.sleep(0.1) - i+=1 - data['mongos']['serverstatus']=0 - if types=='restart' or types=='start': #启动服务 - i=1 - for k in data['mongos']['server']: - startstatus=False - cmd="mongos --bind_ip "+str(k['ip'])+" --port "+str(k['port'])+" -f "+WORK_DIR+"/conf/mongos.conf --logpath "+WORK_DIR+"/mongos/log"+str(i)+".log --pidfilepath "+WORK_DIR+"/mongos/db"+str(i)+".pid" - print(cmd) - result=os.popen(cmd) - res = result.read() - for line in res.splitlines(): - print("line",line) - if 'process started successfully' in line: - startstatus=True - break - if not startstatus: - return errorjson(code=1,msg="启动失败") - i+=1 - data['mongos']['serverstatus']=1 - file_set_content(WORK_DIR+"/config.conf",json_encode(data)) - return successjson() -def start_shard(types='restart'): - '启动/停止分片服务' - data=request.get_json() - data['key']='' - os.system("mkdir -p "+WORK_DIR+"/conf") - - j=1 - for shard in data['shard']:#分片列表 - f=open(WORK_DIR+"/conf/shard"+str(j)+".conf","w") - f.write("logappend=true\n"+ - "fork=true\n"+ - "maxConns=2000\n"+ - "storageEngine=mmapv1 #基于内存映射文件的存储引擎\n"+ - "shardsvr=true\n"+ - "replSet="+shard['servername']+"\n"+ - "keyFile="+WORK_DIR+"/key/mongo.key") - f.close() - i=1 - for k in shard['server']: - os.system("mkdir -p "+WORK_DIR+"/shard"+str(j)+"/data"+str(i)) - i+=1 - if types=='restart' or types=='stop': #停止服务 - i=1 - for k in shard['server']: - pid=file_get_content(WORK_DIR+"/shard"+str(j)+"/db"+str(i)+".pid") - os.system("kill -9 "+str(pid)) - time.sleep(0.1) - i+=1 - data['shard'][j-1]['serverstatus']=0 - if types=='restart' or types=='start': #启动服务 - i=1 - for k in shard['server']:#副本集列表 - startstatus=False - cmd="mongod --bind_ip "+str(k['ip'])+" --port "+str(k['port'])+" -f "+WORK_DIR+"/conf/shard"+str(j)+".conf --dbpath "+WORK_DIR+"/shard"+str(j)+"/data"+str(i)+" --logpath "+WORK_DIR+"/shard"+str(j)+"/log"+str(i)+".log --pidfilepath "+WORK_DIR+"/shard"+str(j)+"/db"+str(i)+".pid" - print("启动cmd:",cmd) - result=os.popen(cmd) - res = result.read() - for line in res.splitlines(): - print("line",line) - if 'process started successfully' in line: - startstatus=True - break - if not startstatus: - file_set_content(WORK_DIR+"/config.conf",json_encode(data)) - return errorjson(code=1,msg="启动失败") - i+=1 - data['shard'][j-1]['serverstatus']=1 - j+=1 - file_set_content(WORK_DIR+"/config.conf",json_encode(data)) - return successjson() - -# def config_init(id): -# "config副本集初始化," -# data=request.get_json() -# port=data['configs']['server'][0]['port'] -# replicaset=data['configs']['replicaset'] -# members=[] -# i=0 -# for k in replicaset: -# zd={'_id':i,'host':k['ip']+':'+str(k['port'])} -# members.append(zd) -# i+=1 -# f=open(config.path['path']+"app/linuxweb/config_init.sh","w") -# f.write("mongo --port "+str(port)+"\n"+ -# "use admin\n"+ -# "rs.initiate({_id:'configs',members:"+json_encode(members)+"})\n"+ -# "exit") -# f.close() -# os.system("cd "+config.path['path']+"app/linuxweb && bash config_init.sh") -# return successjson() - - - -#mongodb独立部署 /data/mongodb/server1/ -def setserverconfig(): - configlist=request.get_json() - for k in configlist: - if not os.path.exists(WORK_DIR+k['path']): - os.makedirs(WORK_DIR+k['path']) - if not os.path.exists(WORK_DIR+k['path']+"/data"): - os.makedirs(WORK_DIR+k['path']+"/data") - file_set_content(WORK_DIR+k['path']+"/mongod.config",''+ - 'systemLog:\n'+ - ' destination: file\n'+ - ' logAppend: true\n'+ - ' path: '+WORK_DIR+k['path']+'/mongodb.log #mongodb的日志文件路径\n'+ - 'storage:\n'+ - ' dbPath: '+WORK_DIR+k['path']+'/data/ #mongodb的数据文件路径\n'+ - ' journal:\n'+ - ' enabled: true\n'+ - 'processManagement:\n'+ - ' fork: true # fork and run in background\n'+ - ' pidFilePath: '+WORK_DIR+k['path']+'/mongod.pid # location of pidfile\n'+ - ' timeZoneInfo: /usr/share/zoneinfo\n'+ - 'net:\n'+ - ' port: '+str(k['port'])+' #mongodb1的进程号\n'+ - ' bindIp: '+k['bindIp']+' # Listen to local interface only, comment to listen on all interfaces') - file_set_content(WORK_DIR+"/serverconfig.conf",json_encode(configlist)) - return successjson() -def restartserver(types='start',index=0): - index=int(index) - configlist=json_decode(file_get_content(WORK_DIR+"/serverconfig.conf")) - cmd="mongod -f "+WORK_DIR+configlist[index]['path']+"/mongod.config" #启动命令 - if types=='start': - configlist[index]['status']=1 - system_start.insert_Boot_up(cmd=cmd,name="mongodb独立模式") - elif types=='stop': - configlist[index]['status']=0 - system_start.del_Boot_up(cmd) - cmd=cmd+" --shutdown" #停止命令 - result=os.popen(cmd) - res = result.read() - startstatus=False - for line in res.splitlines(): - print("line",line) - if 'process started successfully' in line or 'killing process with pid' in line: - startstatus=True - break - if startstatus: - file_set_content(WORK_DIR+"/serverconfig.conf",json_encode(configlist)) - return successjson() - else: - return errorjson(cmd,msg="失败") diff --git a/app/intapp/controller/soft/mysql.py b/app/intapp/controller/soft/mysql.py deleted file mode 100644 index 114b3bb..0000000 --- a/app/intapp/controller/soft/mysql.py +++ /dev/null @@ -1,254 +0,0 @@ -from .common import * -import oss2 -def get_data(id): - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - text=file_get_content(ar['paths']+ar['title']+ar['edition']+"/config.conf") - conf=json_decode(text) - if not conf: - conf={ - "base":{'rootpassword':'intapppasswordtest','path':ar['paths']+ar['title']+ar['edition']+'/data'}, - } - data={ - 'conf':conf, - 'ar':ar, - "my":file_get_content("/etc/my.cnf") - } - return successjson(data) -def upd_my(): - "修改配置文件" - data=request.get_json() - file_set_content("/etc/my.cnf",data['text']) - return successjson() -def upd_data(id): - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - data=request.get_json() - filetext=file_get_content(ar['paths']+ar['title']+ar['edition']+"/config.conf") - filedata=json_decode(filetext) - if not filedata or data['base']['rootpassword']!=filedata['base']['rootpassword']:#修改mysql密码 - os.system("mysqld restart --skip-grant-tables") - cmd="mysql -uroot -e " - cmd=cmd+'"use mysql;flush privileges;update user set authentication_string=password(' - cmd=cmd+"'"+str(data['base']['rootpassword']) - cmd=cmd+"'" - cmd=cmd+') where user=' - cmd=cmd+"'root';set password=password('"+str(data['base']['rootpassword'])+"');" - cmd=cmd+'"' - pi=subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) - ars=pi.stdout.read().decode() - ars=ars.split("\n") - strs=ars[len(ars)-2] - os.system("mysqld restart") - print(type(strs),strs) - if 'error' in strs: - return errorjson(msg="密码修改失败"+strs) - - # mysqld restart --skip-grant-tables && mysql -uroot -e "flush privileges;update mysql.user set authentication_string=password('123456') where user = 'root'"; - # print(data['base']['rootpassword'],filedata['base']['rootpassword']) - if not filedata or data['base']['path']!=filedata['base']['path']: - os.system('mysqld stop') - os.system("mkdir -p "+str(data['base']['path'])) - if not filedata: - print("cp -r "+ar['paths']+ar['title']+ar['edition']+"/data/. "+data['base']['path']+"/") - os.system("cp -r "+ar['paths']+ar['title']+ar['edition']+"/data/. "+data['base']['path']+"/") - else: - print("cp -r "+filedata['base']['path']+"/. "+data['base']['path']+"/") - os.system("cp -r "+filedata['base']['path']+"/. "+data['base']['path']+"/") - os.system("chown -R mysql "+str(data['base']['path'])+" && chgrp -R mysql "+str(data['base']['path'])) - - f = open('/etc/my.cnf') - con='' - while True: - line = f.readline() - if not line: - break - elif 'datadir=' in line: - line="datadir="+str(data['base']['path'])+"\n" - con=con+line - f.close() - f= open('/etc/my.cnf', "w") - f.write(con) - f.close() - time.sleep(1) - os.system('mysqld start') - text=json_encode(data) - file_set_content(ar['paths']+ar['title']+ar['edition']+"/config.conf",text) - - return successjson() -def backups(types='whole',db='bankup_all_databases',upload_aliyun=True): - "备份mysql" - return BACKUP.backups(types,db,upload_aliyun) -def recovery(types='whole',upload_aliyun=True): - "恢复mysql" - db=request.args.get("db") - Queues.insert(target=BACKUP.recovery,args=(types,db,upload_aliyun),title="恢复mysql") - return successjson(msg="正在恢复数据库,请在任务队列中查看恢复结果") -class BACKUP: - def recovery(types,db,upload_aliyun): - """恢复数据库""" - if not os.path.isfile("app/common/file/config.conf"): - print("在系统配置中保存备份目录") - return - fileconfig=json_decode(file_get_content("app/common/file/config.conf")) - if not fileconfig: - print("在系统配置中保存备份目录") - return - backpath=fileconfig['aliyun']['backpath'] - if backpath: - if backpath[:1]=='/': - backpath=backpath[1:] - if backpath[-1]=='/': - backpath=backpath[:-1] - else: - backpath="kcweb" - backmysqlpath="backup/mysql" #mysql备份目录 - if not os.path.exists(backmysqlpath): - os.makedirs(backmysqlpath) - mysqlpwd='intapppasswordtest' - mysqlconf=json_decode(file_get_content("/usr/local/mysql/mysql5.7/config.conf")) #mysql信息 - if mysqlconf: - mysqldatapath=mysqlconf['base']['path'] - mysqlpwd=mysqlconf['base']['rootpassword'] - conf={ - "mysql":{ - "username":"root","password":mysqlpwd,"host":"127.0.0.1",#mysql信息 - }, - } - if upload_aliyun: - auth = oss2.Auth(fileconfig['aliyun']['access_key'],fileconfig['aliyun']['access_key_secret']) - bucket = oss2.Bucket(auth,fileconfig['aliyun']['address'],fileconfig['aliyun']['bucket']) - bucket.get_object_to_file(db,backmysqlpath+"/database.sql.gz") - os.system("gzip -d "+backmysqlpath+"/database.sql.gz") - os.system("mysql -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" < "+backmysqlpath+"/database.sql") - os.remove(backmysqlpath+"/database.sql") - else: - os.system("gzip -d "+backmysqlpath+"/"+db+".sql.gz") - os.system("mysql -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" < "+backmysqlpath+"/"+db+".sql") - print("恢复完成") - def backups(types,db,upload_aliyun): - """备份mysql --cli运行 - types whole表示全量备份。 increment表示增量备份所有 - - db bankup_all_databases表示备份所有数据库。 否则备份指定数据库按逗号分隔 types=whole时有效 - """ - if not os.path.isfile("app/common/file/config.conf"): - print("在系统配置中保存备份目录") - return - fileconfig=json_decode(file_get_content("app/common/file/config.conf")) - if not fileconfig: - print("在系统配置中保存备份目录") - return - backpath=fileconfig['aliyun']['backpath'] - if backpath: - if backpath[:1]=='/': - backpath=backpath[1:] - if backpath[-1]=='/': - backpath=backpath[:-1] - else: - backpath="kcweb" - backmysqlpath="backup/mysql" #mysql备份目录 - if not os.path.exists(backmysqlpath): - os.makedirs(backmysqlpath) - mysqldatapath="/usr/local/mysql/mysql5.7/data" #mysql数据库存放目 - mysqlpwd='intapppasswordtest' - mysqlconf=json_decode(file_get_content("/usr/local/mysql/mysql5.7/config.conf")) #mysql信息 - if mysqlconf: - mysqldatapath=mysqlconf['base']['path'] - mysqlpwd=mysqlconf['base']['rootpassword'] - conf={ - "mysql":{ - "username":"root","password":mysqlpwd,"host":"127.0.0.1",#mysql信息 - }, - } - if upload_aliyun: - auth = oss2.Auth(fileconfig['aliyun']['access_key'],fileconfig['aliyun']['access_key_secret']) - bucket = oss2.Bucket(auth,fileconfig['aliyun']['address'],fileconfig['aliyun']['bucket']) - if types=='whole': #全量备份 - if not os.path.exists(backmysqlpath): - os.system("mkdir -p "+backmysqlpath) - if db=='bankup_all_databases':#备份所有 - print("全量备份所有数据库:"+db+".sql.gz") - os.system("mysqldump -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" --all-databases --flush-logs --delete-master-logs --single-transaction | gzip >> "+backmysqlpath+"/"+db+".sql.gz") - else:#备份指定数据库 - db=re.sub(","," ",db) - print("全量备份指定数据库:"+db+".sql.gz") - os.system("mysqldump -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" --databases --flush-logs --delete-master-logs --single-transaction | gzip >> "+backmysqlpath+"/"+db+".sql.gz") - if upload_aliyun: - print(backmysqlpath+"/"+db+".sql.gz","上传mysql备份目录文件到阿里云oss...") - oss2.resumable_upload(bucket, "backups/"+backpath+"/"+backmysqlpath+"/"+db+"/"+time.strftime("%Y%m%d-%H:%M:%S",time.localtime(times()))+".sql.gz",backmysqlpath+"/"+db+".sql.gz") - filelist=[] - for obj in oss2.ObjectIterator(bucket, prefix="backups/"+backpath+"/"+backmysqlpath+"/"+db+"/"): - filelist.append(obj.key) - i=0 - while True: - if len(filelist)-i <= 5: #在阿里云保留5个备份文件 其他上传 - break - bucket.delete_object(filelist[i]) - i+=1 - - # elif types=='increment': #增量备份所有 - # if not os.path.exists(backmysqlpath) or not os.path.isfile(backmysqlpath+"/"+db+".sql.gz"): - # os.system("mkdir -p "+backmysqlpath) - # print("全量备份所有数据库:"+db+".sql.gz") - # os.system("mysqldump -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" --all-databases --flush-logs --delete-master-logs --single-transaction | gzip >> "+backmysqlpath+"/increment_all_databases.sql.gz") - # print("备份mysql二进制文件...") - # t=os.listdir(backmysqlpath) - # lis=os.listdir(mysqldatapath) - # maxlist=[] - # for files in lis: - # if 'mysql-bin.' in files: - # try: - # a=int(files.replace("mysql-bin.", "")) - # maxlist.append(a) - # except:pass - # for files in lis: - # iscz=True #是否需要复制 - # if iscz: - # for k in t: - # if mysqldatapath+"/"+k == mysqldatapath+"/"+files: - # iscz=False - # print(mysqldatapath+"/"+k+"已存在") - # break - # if not iscz: - # if 'mysql-bin.' in files: - # try: - # a=int(files.replace("mysql-bin.", "")) - # if max(maxlist) == a: - # iscz=True - # print(mysqldatapath+"/"+files+"该文件是最后一个日志,已备份,(最后一个文件可能不是完整的)") - # except:pass - # if iscz: - # if 'mysql-bin.' in files: - # try: - # a=int(files.replace("mysql-bin.", "")) - # os.system("cp -f "+mysqldatapath+"/"+files+" "+backmysqlpath+"/"+files) - # print("cp -f "+mysqldatapath+"/"+files+" "+backmysqlpath+"/"+files,"复制成功") - # except:pass - # if upload_aliyun: - # print("上传mysql备份目录文件到阿里云oss...") - # t=os.listdir(backmysqlpath) - # maxlist=[] - # for files in t: - # if 'mysql-bin.' in files: - # try: - # a=int(files.replace("mysql-bin.", "")) - # maxlist.append(a) - # except:pass - # path=get_file(backmysqlpath,is_folder=False) - # for files in path: - # sc=True #是否需要上传 - # if bucket.object_exists("backups/"+files['path']):#如果文件已存在阿里云 - # if 'mysql-bin.' in files['name']: - # try: - # a=int(files['name'].replace("mysql-bin.", "")) - # if max(maxlist) == a: - # print(backmysqlpath+"/"+files['name']+"该文件是最后一个日志,所以要上传阿里云") - # else: - # print("文件已在阿里云oss存在") - # sc=False - # except:pass - # else: - # print("文件已在阿里云oss存在") - # sc=False - # if sc: - # oss2.resumable_upload(bucket, "backups/"+files['path'], files['path']) - print("备份完成") diff --git a/app/intapp/controller/soft/nginx.py b/app/intapp/controller/soft/nginx.py deleted file mode 100644 index 09e4418..0000000 --- a/app/intapp/controller/soft/nginx.py +++ /dev/null @@ -1,360 +0,0 @@ -from .common import * -import traceback -def index(id='',types='getinfo'): - "nginx配置文件" - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - paths=ar['paths'] - filenames=ar['title'] - edition=ar['edition'] - if types=='getinfo': - if os.path.isfile(paths+filenames+edition+'/logs/error.log'): - # print(paths+filenames+'/logs/error.log') - # f=open(paths+filenames+'/logs/error.log','r') - # logserror=f.read() - # f.close() - logserror='' - else:logserror='' - if os.path.isfile(paths+filenames+edition+'/logs/access.log'): - # f=open(paths+filenames+'/logs/access.log','r',encoding="utf-8") - # logsaccess=f.read() - # f.close() - logsaccess='' - else:logsaccess='' - f=open(paths+filenames+edition+'/conf/nginx.conf','r',encoding="utf-8") - confnginx=f.read() - data={ - 'logs':{'error':logserror,'access':logsaccess}, - 'conf':{'nginx':confnginx}, - } - return successjson(data) - elif types=='updconf': - con=request.get_json() - f=open(paths+filenames+edition+'/conf/nginx.conf','w',encoding="utf-8") - f.write(con['text']) - f.close() - return successjson() - else: - return errorjson(msg="未知类型") -def anphp(): - "已安装的php以及伪静态模板" - nginx=sqlite('soft',model_intapp_soft_path).where([('status','egt','4'),'and',('platform','eq',get_sysinfo()['uname'][0]),'and',('title','like','nginx%')]).find() - if nginx: - pseudo_static_tpl=get_file(nginx['paths']+nginx['title']+nginx['edition']+'/conf/vhost/webtpl/rewrite') #伪静态模板 - rewr=[] - for k in pseudo_static_tpl: - rewr.append({'name':k['name'],'text':file_get_content(k['path'])}) - data={ - "php":sqlite('soft',model_intapp_soft_path).where("title like '%php%' and (status=4 or status=10) and title not like '%phpmyadmin%'").select(), - "rewr":rewr - } - return successjson(data) - else: - return successjson() -def webdescribesfind(): - "获取指定网站信息" - title=request.args.get("title") - return successjson(sqlite("web",model_intapp_soft_path).where("title='"+title+"'").find()) -def weblist(): - "网站列表" - where=False - pagenow=int(request.args.get('pagenow')) - pagesize=int(request.args.get('pagesize')) - kw=request.args.get('kw') - if kw: - where=[("title","like","%"+str(kw)+"%"),'or',("describes","like","%"+str(kw)+"%"),'or',("domain","like","%"+str(kw)+"%")] - if not pagenow: - pagenow=1 - if not pagesize: - pagesize=10 - lists=sqlite("web",model_intapp_soft_path).where(where).page(pagenow,pagesize).select() - i=0 - for k in lists: - # lists[i]['domain']=k['domain'].split("\n") - lists[i]['balancing'] =json_decode(k['balancing']) - lists[i]['proxy_set_header'] =json_decode(k['proxy_set_header']) - lists[i]['header'] =json_decode(k['header']) - i+=1 - count=sqlite("web",model_intapp_soft_path).where(where).count() - return successjson(return_list(lists,count,pagenow,pagesize)) -def add_web(): - "添加或更新网站" - nginx=sqlite('soft',model_intapp_soft_path).where([('status','egt','4'),'and',('platform','eq',get_sysinfo()['uname'][0]),'and',('title','like','nginx%')]).find() - if not nginx: - return errorjson(msg='安装nginx服务器后才创建网站') - addtime=times() - data=request.get_json() - if data['domain']=='': - return errorjson(msg="域名不能为空") - if data['port']=='': - return errorjson(msg="端口不能为空") - if data['client_max_body_size']=='': - return errorjson(msg="上传限制不能为空") - if data['path']=='': - data['path']="/www/wwwroot/" - # return errorjson(msg="网站目录不能为空") - paths=nginx['paths'] - try: - ttt1=data['domain'].split("\n") - if data['id']: - where="port="+str(data['port'])+" and id != "+str(data['id'])+" and (" #[('port','eq',data['port'])] - for kk in ttt1: - where=where+"domain like '%"+kk+"%'"+" or " - where=where[:-4]+")" - ttt2=sqlite('web',model_intapp_soft_path).where(where).find() - if ttt2: - ttt2=ttt2['domain'].split("\n") - for k in ttt2: - for kk in ttt2: - if k==kk: - return errorjson(msg=k+"已在本服务器其他站点使用被使用") - domains=sqlite('web',model_intapp_soft_path).where("id",data['id']).field("only").find()['only'] - else: - where="port="+data['port']+" and (" - for kk in ttt1: - where=where+"domain like '%"+kk+"%'"+" or " - where=where[:-4]+")" - domains=ttt1[0]+":"+str(data['port']) - data['only']=domains - ttt=sqlite('web',model_intapp_soft_path).where(where).find() - if ttt: - ttt=ttt['domain'].split("\n") - for k in ttt: - for kk in ttt1: - if k==kk: - return errorjson(msg=k+"已被使用") - ttt=data['domain'].split("\n") - server_name='' - for k in ttt: - server_name=str(server_name)+" "+str(k) - - if nginx['platform']=='Linux': - if data['webtpl']=='': - return errorjson(msg="请选择配置文件模板") - filenames=nginx['title']+nginx['edition'] - servertpl=paths+filenames+'/conf/vhost/webtpl/'+data['webtpl'] - ssl_certificate="" - ssl_certificate_key="" - try: - ssl_certificate=data['ssl_certificate'] - ssl_certificate_key=data['ssl_certificate_key'] - except: - data['ssl_certificate']='' - data['ssl_certificate_key']='' - try: - data['header'] - except: - data['header']='' - try: - data['ssl'] - except: - data['ssl']='' - try: - data['rewrite'] - except: - data['rewrite']='' - if data['ssl']: - ssl=443 - if len(data['ssl_certificate'])>5 and len(data['ssl_certificate_key'])>5: - ssl_certificate=data['ssl_certificate'] - ssl_certificate_key=data['ssl_certificate_key'] - # print(ssl_certificate_key) - else: - key=paths+filenames+'/conf/vhost/rewrite/'+domains+".key" - pem=paths+filenames+'/conf/vhost/rewrite/'+domains+".pem" - file_set_content(key,data['key']) - file_set_content(pem,data['pem']) - ssl_certificate=paths+filenames+"/conf/vhost/rewrite/"+domains+".pem" - ssl_certificate_key=paths+filenames+"/conf/vhost/rewrite/"+domains+".key" - print(ssl_certificate) - else: - if os.path.isfile(paths+filenames+'/conf/vhost/rewrite/'+domains+".key") and os.path.isfile(paths+filenames+'/conf/vhost/rewrite/'+domains+".pem"): - sslttt1=file_get_content(paths+filenames+'/conf/vhost/rewrite/'+domains+".key") - sslttt2=file_get_content(paths+filenames+'/conf/vhost/rewrite/'+domains+".pem") - if len(sslttt1)>10 and len(sslttt2)>10: - ssl=443 - else: - ssl=False - else: - ssl=False - if 'php' in data['webtpl'] and len(data['rewrite'])>4:#php伪静态 - file_set_content(paths+filenames+"/conf/vhost/rewrite/"+domains,data['rewrite']) - elif not os.path.isfile(paths+filenames+"/conf/vhost/rewrite/"+domains): - file_set_content(paths+filenames+"/conf/vhost/rewrite/"+domains,'') - if data['webtpl']=='static' or data['webtpl']=='vue' or 'php' in data['webtpl']: - - text=Templates(servertpl,client_max_body_size=data['client_max_body_size'],port=data['port'],ssl=ssl,ssl_certificate=ssl_certificate,ssl_certificate_key=ssl_certificate_key, - server_name=server_name,webpath=data['path'],rewrite=paths+filenames+"/conf/vhost/rewrite/"+domains,domains=domains,header=data['header']) - elif data['webtpl']=='balancing':#添加负载均衡 - balancing=data['balancing'] #负载均衡列表 - proxy_set_header=data['proxy_set_header'] #自定义转发请求头列表 - for k in data['balancing']: - if k['ip']=='' or k['port']=='': - return errorjson(msg="请填写负载均衡ip和端口") - text=Templates(servertpl,client_max_body_size=data['client_max_body_size'],port=data['port'],ssl=ssl,balancing=balancing,proxy_set_header=proxy_set_header,ssl_certificate=ssl_certificate,ssl_certificate_key=ssl_certificate_key, - server_name=server_name,webpath=data['path'],rewrite=paths+filenames+"/conf/vhost/rewrite/"+domains,domains=domains,header=data['header']) - f=open(paths+filenames+"/conf/vhost/"+domains+'.conf','w',encoding="utf-8") - f.write(text) - f.close() - os.system("nginx -s reload") - if not os.path.exists(data['path']): - os.makedirs(data['path']) - f=open(data['path']+"/index.html",'w',encoding="utf-8") - f.write('网站创建成功

恭喜您!网站创建成功

') - f.close() - f=open(data['path']+"/index.php",'w',encoding="utf-8") - f.write("") - f.close() - try: - data['servers']=paths+filenames - except:pass - try: - del data['key'] - del data['pem'] - except:pass - del data['ssl'] - del data['rewrite'] - data['balancing'] =json_encode(data['balancing']) - data['proxy_set_header'] =json_encode(data['proxy_set_header']) - data['header'] =json_encode(data['header']) - if data['id']: - data['updtime']=addtime - data['status']=1 - sqlite('web',model_intapp_soft_path).where("id",data['id']).update(data) - pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) - ars=pi.stdout.read().decode() - ars=ars.split("\n") - strs=ars[len(ars)-2] - if len(strs) > 1: - return errorjson(msg=strs) - else: - del data['id'] - data['addtime']=addtime - data['updtime']=addtime - sqlite('web',model_intapp_soft_path).insert(data) - except: - print(traceback.format_exc()) - return errorjson(msg="失败,检查参数是否有误") - else: - return successjson() -def del_web(id=0,path=0): - #path=1 表示删除网站目录 ,linux和windows已完成 - "删除网站" - title=request.args.get("title") - if not id and title: - where="title = '"+title+"'" - else: - where="id='"+str(id)+"'" - nginx=sqlite('web',model_intapp_soft_path).where(where).find() - if not nginx: - return successjson(msg="不存在") - print(nginx) - filenames=nginx['servers'] - if get_sysinfo()['uname'][0]=='Linux': - if os.path.isfile(filenames+"/conf/vhost/"+nginx['only']+'.conf'): - os.remove(filenames+"/conf/vhost/"+nginx['only']+'.conf') - if os.path.isfile(filenames+"/conf/vhost/rewrite/"+nginx['only']): - os.remove(filenames+"/conf/vhost/rewrite/"+nginx['only']) - if os.path.isfile(filenames+"/logs/"+nginx['only']+".access.log"): - os.remove(filenames+"/logs/"+nginx['only']+".access.log") - if os.path.isfile(filenames+'/conf/vhost/rewrite/'+nginx['only']+".key"): - os.remove(filenames+'/conf/vhost/rewrite/'+nginx['only']+".key") - if os.path.isfile(filenames+'/conf/vhost/rewrite/'+nginx['only']+".pem"): - os.remove(filenames+'/conf/vhost/rewrite/'+nginx['only']+".pem") - pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) - ars=pi.stdout.read().decode() - ars=ars.split("\n") - strs=ars[len(ars)-2] - elif get_sysinfo()['uname'][0]=='Windows': - if os.path.isfile(filenames+"/conf/vhost/"+nginx['only']+'.conf'): - os.remove(filenames+"/conf/vhost/"+nginx['only']+'.conf') - if os.path.isfile(filenames+"/conf/vhost/rewrite/"+nginx['only']): - os.remove(filenames+"/conf/vhost/rewrite/"+nginx['only']) - if os.path.isfile(filenames+"/logs/"+nginx['only']+".access.log"): - os.remove(filenames+"/logs/"+nginx['only']+".access.log") - os.system("cd "+filenames+" & stop.bat") - time.sleep(3) - os.system("cd "+filenames+" & start.bat") - else: - return errorjson(msg="无法匹配系统") - if path=='1' and os.path.exists(nginx['path']): - shutil.rmtree(nginx['path']) - sqlite('web',model_intapp_soft_path).where(where).delete() - pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) - ars=pi.stdout.read().decode() - ars=ars.split("\n") - strs=ars[len(ars)-2] - if len(strs) > 1: - return errorjson(msg=strs) - return successjson() - -def getssl(id): - ar=sqlite('web',model_intapp_soft_path).where('id',id).find() - key=ar['servers']+'/conf/vhost/rewrite/'+ar['only']+".key" - pem=ar['servers']+'/conf/vhost/rewrite/'+ar['only']+".pem" - data={ - "key":file_get_content(key), - "pem":file_get_content(pem) - } - return successjson(data) -def getrewr(id): - "获取伪静态" - ar=sqlite('web',model_intapp_soft_path).where('id',id).find() - return successjson(file_get_content(ar['servers']+'/conf/vhost/rewrite/'+ar['only'])) -def getconfig(id,types='get'): - "获取配置文件" - ar=sqlite('web',model_intapp_soft_path).where('id',id).find() - if types=='get': - return successjson(file_get_content(ar['servers']+'/conf/vhost/'+ar['only']+".conf")) - elif types=='set': - data=request.get_json() - file_set_content(ar['servers']+'/conf/vhost/'+ar['only']+".conf",data['text']) - pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) - ars=pi.stdout.read().decode() - ars=ars.split("\n") - strs=ars[len(ars)-2] - if len(strs) > 1: - return errorjson(msg=strs) - return successjson() - - -def sslfolde(): - "Let's Encrypt证书夹" - paths="/etc/letsencrypt/live/" - if not os.path.exists(paths): - return errorjson(code=1,msg="Let's Encrypt证书夹不存在,在插件市场安装LetsEncrypt插件创建证书后再使用该功能") - try: - lis=os.listdir(paths) - except: - return errorjson(code=1,msg="无法打开"+str(paths)) - lists=[] - for files in lis: - types="folder" - config={} - if os.path.isfile(paths+"/"+files): - types="file" - else: - config=file_get_content(paths+"/"+files+"/config.conf") - if config: - config=json_decode(config) - zd={"name":files,"types":types,"config":config} - lists.append(zd) - data=return_list(lists,count=len(lis),pagenow=1,pagesize=len(lis)) - data['paths']=paths - "文件列表" - return successjson(data) -def ssltpl(): - "Let's Encrypt证书内容" - name=request.args.get("name") - paths="/etc/letsencrypt/live/"+name - chain=file_get_content(paths+"/chain.pem") - fullchain=file_get_content(paths+"/fullchain.pem") - privkey=file_get_content(paths+"/privkey.pem") - cert=file_get_content(paths+"/cert.pem") - data={ - "chain":chain, - "fullchain":fullchain, - "privkey":privkey, - "cert":cert - } - return successjson(data) - \ No newline at end of file diff --git a/app/intapp/controller/soft/page.py b/app/intapp/controller/soft/page.py deleted file mode 100644 index 0dc48f6..0000000 --- a/app/intapp/controller/soft/page.py +++ /dev/null @@ -1,13 +0,0 @@ -from .common import * -def home(): - return response.tpl("index/home") -def pub(html): - return response.tpl("page/%s" % html) -def s(fun,html): - id=request.args.get("id") - return response.tpl("%s/%s" % (fun,html),id=id) -def soft(html): - id=request.args.get("id") - types=request.args.get("types") - data=sqlite("soft",model_intapp_soft_path).where("id",id).find() - return response.tpl("soft/%s" % html,id=id,data=data,types=types) \ No newline at end of file diff --git a/app/intapp/controller/soft/php.py b/app/intapp/controller/soft/php.py deleted file mode 100644 index 5c1e94b..0000000 --- a/app/intapp/controller/soft/php.py +++ /dev/null @@ -1,266 +0,0 @@ -from .common import * -def ini(id,is_upd=0): - "php.ini配置文件" - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - paths=ar['paths'] - filenames=ar['title']+ar['edition'] - if ar['platform']=='Linux': - filepath=paths+filenames+"/bin/php.ini" - elif ar['platform']=='Windows': - filepath=paths+filenames+"/php.ini" - else: - return errorjson(code=1,msg="不支持此时平台") - if is_upd: #修改配置 - data=request.get_json() - file_set_content(filepath,data['text']) - return successjson() - else: - data={ - 'ini':file_get_content(filepath), - 'php':ar - } - return successjson(data) -def www_conf(id,is_upd=0): - "www.conf配置文件" - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - paths=ar['paths'] - filenames=ar['title']+ar['edition'] - if ar['platform']=='Linux': - filepath=paths+filenames+"/etc/php-fpm.d/www.conf" - if 'php5.6' in filenames: - filepath=paths+filenames+"/etc/php-fpm.conf" - elif ar['platform']=='Windows': - filepath='' - else: - return errorjson(code=1,msg="不支持此时平台") - if is_upd: #修改配置 - data=request.get_json() - file_set_content(filepath,data['text']) - return successjson() - else: - data={ - 'www_conf':file_get_content(filepath), - 'php':ar - } - return successjson(data) -def phpfpm(id,is_upd=0): - "phpfpm配置信息" - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - paths=ar['paths'] - filenames=ar['title']+ar['edition'] - if ar['platform']=='Linux': - if not os.path.exists(paths+filenames+"/bin/conf"): - os.makedirs(paths+filenames+"/bin/conf") - filepath=paths+filenames+"/bin/conf/phpfpm.conf" - phpfpmpath=paths+filenames+"/etc/php-fpm.d/www.conf" - if 'php5.6' in filenames: - phpfpmpath=paths+filenames+"/etc/php-fpm.conf" - else: - filepath='' - phpfpmpath='' - if is_upd: #修改php-fpm配置信息 - data=request.get_json() - f = open(phpfpmpath) - con='' - while True: - line = f.readline() - if not line: - break - elif 'pm = ' in line and '=' in line: #运行描述 - line="pm = "+data['text']['pm']+"\n" - elif 'pm.max_children' in line and '=' in line:# 允许创建的最大子进程数 - line="pm.max_children = "+data['text']['max_children']+"\n" - elif 'pm.start_servers' in line and '=' in line:# 起始进程数(服务启动后初始进程数量) - line="pm.start_servers = "+data['text']['start_servers']+"\n" - elif 'pm.min_spare_servers' in line and '=' in line:# 起始进程数(服务启动后初始进程数量) - line="pm.min_spare_servers = "+data['text']['min_spare_servers']+"\n" - elif 'pm.max_spare_servers' in line and '=' in line:# 最大空闲进程数(当空闲进程达到此值时清理) - line="pm.max_spare_servers = "+data['text']['max_spare_servers']+"\n" - con=con+line - f.close() - f= open(phpfpmpath, "w") - f.write(con) - f.close() - file_set_content(filepath,json_encode(data['text'])) - return successjson() - else: - phpfpm=json_decode(file_get_content(filepath)) - if not phpfpm: - phpfpm='' - data={ - 'phpfpm':phpfpm, - 'php':ar - } - return successjson(data) -def base(id,is_upd=0): - "基本配置信息" - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - paths=ar['paths'] - filenames=ar['title']+ar['edition'] - if ar['platform']=='Linux': - if not os.path.exists(paths+filenames+"/bin/conf"): - os.makedirs(paths+filenames+"/bin/conf") - filepath=paths+filenames+"/bin/conf/base.ini" - phpinipath=paths+filenames+"/bin/php.ini" - elif ar['platform']=='Windows': - if not os.path.exists(paths+filenames+"/conf"): - os.makedirs(paths+filenames+"/conf") - filepath=paths+filenames+"/conf/base.ini" - phpinipath=paths+filenames+"/php.ini" - if is_upd: #修改基本配置信息 - #修改php.ini配置 - data=request.get_json() - f = open(phpinipath) - con='' - while True: - line = f.readline() - if not line: - break - elif 'max_execution_time' in line and '=' in line:#最大执行时间 - line="max_execution_time = "+data['text']['max_execution_time']+"\n" - elif 'max_input_time' in line and '=' in line:#最大输入时间 - line="max_input_time = "+data['text']['max_input_time']+"\n" - elif 'memory_limit' in line and '=' in line:#内存限制 - line="memory_limit = "+data['text']['memory_limit']+"M\n" - elif 'file_uploads' == line[0:12] and '=' in line:#是否允许文件上传 - line="file_uploads = "+data['text']['file_uploads']+"\n" - elif 'upload_max_filesize' in line and '=' in line:#上传大小限制 - line="upload_max_filesize = "+data['text']['upload_max_filesize']+"M\n" - elif 'max_file_uploads' in line and '=' in line:#上传数量限制 - line="max_file_uploads = "+data['text']['max_file_uploads']+"\n" - elif 'post_max_size' in line and '=' in line:#上传数量限制 - line="post_max_size = "+data['text']['post_max_size']+"M\n" - elif 'allow_url_fopen' in line and '=' in line: - line="allow_url_fopen = "+data['text']['allow_url_fopen']+"\n" - elif 'allow_url_include' in line and '=' in line: - line="allow_url_include = "+data['text']['allow_url_include']+"\n" - elif 'default_socket_timeout' in line and '=' in line: - line="default_socket_timeout = "+data['text']['default_socket_timeout']+"\n" - con=con+line - f.close() - f= open(phpinipath, "w") - f.write(con) - f.close() - file_set_content(filepath,json_encode(data['text'])) - # print(data['text']) - return successjson() - else: - base=json_decode(file_get_content(filepath)) - if not base: - base='' - data={ - 'base':base, - 'php':ar - } - return successjson(data) -def extenlist(id,is_upd=0): - "php扩展信息列表" - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - lists=sqlite('php_exten',model_intapp_soft_php_exten_path).where('pid',id).select() - data={ - 'extenlist':lists, - 'php':ar - } - return successjson(data) -def log(id): - "待完善" - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - filename=ar['filename'] - paths=ar['paths'] - filenames=ar['title']+ar['edition'] - if ar['platform']=='Linux': - filepath=paths+filenames+"" - elif ar['platform']=='Windows': - filepath=paths+filenames+"" - data={ - 'log':file_get_content(filepath), - 'php':ar - } - return successjson(data) - -def add_php_exten(): - "增加php扩展" - data=request.get_json() - data['addtime']=times() - data['updtime']=times() - sqlite('php_exten',model_intapp_soft_php_exten_path).insert(data) - return successjson() -def del_php_exten(id): - "删除php扩展" - sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',id).delete() - return successjson() - -def installext(id): - is_del=False #是否删除成功 - "安装php扩展和下载扩展" - ar=sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',id).find() - if ar['status']==0: - sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':1,'msg':''}) - Queues.insert(target=__installextqu,args=(ar,),title="安装php-"+ar['title']+"扩展") - elif ar['status']==4: - "卸载扩展" - paths=request.get_json()['paths'] - if get_sysinfo()['uname'][0]=='Linux': - if os.path.exists(paths): - - confile=paths+"bin/php.ini" - f= open(confile, "r") - con='' - while True: - line = f.readline() - if not line: - break - elif str(ar['title']) in line: - line="" - is_del=True - con=con+line - f.close() - f= open(confile, "w") - f.write(con) - f.close() - - # confile=paths+"bin/php.ini" - # f= open(confile, "r") - # con=f.read() - # f.close() - # con=con.replace("extension="+str(ar['title'])+".so\n","") - # f= open(confile, "w") - # f.write(con) - # f.close() - if is_del: - sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':0,'msg':''}) - if 'php7.0' in paths: - os.system("pkill php70-fpm && php70-fpm -c "+paths+"php7.0/etc/php.ini") - elif 'php7.1' in paths: - os.system("pkill php71-fpm && php71-fpm -c "+paths+"php7.1/etc/php.ini") - elif 'php7.2' in paths: - os.system("pkill php72-fpm && php72-fpm -c "+paths+"php7.2/etc/php.ini") - elif 'php7.3' in paths: - os.system("pkill php73-fpm && php73-fpm -c "+paths+"php7.3/etc/php.ini") - elif 'php7.4' in paths: - os.system("pkill php74-fpm && php74-fpm -c "+paths+"php7.4/etc/php.ini") - else: - return errorjson(code=1,msg='卸载失败') - else: - return errorjson(code=1,msg='php文件夹错误') - return successjson() -def get_exten(id): - return successjson(sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',id).find()) -def __installextqu(ar): - "安装php扩展" - sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':3,'msg':''}) - try: - cmd="wget "+config.domain['kcwebfile']+"/"+ar['filename'] - # os.system(cmd) - print(cmd) - pi=subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) - ars=pi.stdout.read().decode() - ars=ars.split("\n") - strs=ars[len(ars)-2] - if 'success' in strs: - sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':4,'msg':''}) - else: - sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':0,'msg':'安装失败'}) - # sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':4,'msg':''}) - except Exception as e: - sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':0,'msg':'安装失败'+str(e)}) \ No newline at end of file diff --git a/app/intapp/controller/soft/redis.py b/app/intapp/controller/soft/redis.py deleted file mode 100644 index df44a4d..0000000 --- a/app/intapp/controller/soft/redis.py +++ /dev/null @@ -1,69 +0,0 @@ -from .common import * -def conf(id,is_upd=0): - "redis配置文件信息" - is_upd=int(is_upd) - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - paths=ar['paths'] - filenames=ar['title']+ar['edition'] - if ar['platform']=='Linux': - filepath=paths+filenames+"/redis.conf" - else: - return errorjson(code=1,msg="不支持此时平台") - if is_upd: #修改配置 - data=request.get_json() - if not data['text']: - return errorjson(code=1,msg='不允许清空配置文件') - file_set_content(filepath,data['text']) - return successjson() - else: - data=file_get_content(filepath) - # print(filepath) - return successjson(data) -def base(id,is_upd=0): - "redis配置文件信息" - is_upd=int(is_upd) - ar=sqlite('soft',model_intapp_soft_path).where('id',id).find() - paths=ar['paths'] - filenames=ar['title']+ar['edition'] - - if ar['platform']=='Linux': - filepath=paths+filenames+"/redis.conf" - jsonpath=paths+filenames+"/redis.json" - else: - return errorjson(code=1,msg="不支持此时平台") - if is_upd: #修改配置 - data=request.get_json() - f = open(filepath) - con='' - while True: - line = f.readline() - if not line: - break - elif 'bind ' in line and '\n' in line and '#' not in line: - line="bind "+data['bind']+"\n" - elif 'port ' in line and '\n' in line and '#' not in line: - line="port "+data['port']+"\n" - elif 'timeout ' in line and '\n' in line and '#' not in line: - line="timeout "+data['timeout']+"\n" - elif 'maxclients ' in line and '\n' in line: - line="maxclients "+data['maxclients']+"\n" - elif 'databases ' in line and '\n' in line and '#' not in line: - line="databases "+data['databases']+"\n" - elif 'requirepass ' in line and '\n' in line: - if data['requirepass']: - line="requirepass "+data['requirepass']+"\n" - else: - line="# requirepass "+data['requirepass']+"\n" - elif 'maxmemory ' in line and '\n' in line and len(line)<20: - line="maxmemory "+data['maxmemory']+"\n" - con=con+line - f.close() - f= open(filepath, "w") - f.write(con) - f.close() - file_set_content(jsonpath,json_encode(data)) - return successjson() - else: - v=file_get_content(jsonpath) - data=json_decode(v) - return successjson(data) \ No newline at end of file diff --git a/app/intapp/controller/soft/role.txt b/app/intapp/controller/soft/role.txt deleted file mode 100644 index 1da7c1d..0000000 --- a/app/intapp/controller/soft/role.txt +++ /dev/null @@ -1,44 +0,0 @@ -#以下是该插件的路由,index容器会自动把以下路由加入到权限管理中 该文件必须使用utf-8编码 -软件页面,/intapp/soft/index/index -软件信息,/intapp/soft/index/gettitle -软件列表,/intapp/soft/index/softlist -更新软件列表,/intapp/soft/index/updatesoftlist -软件状态描述,/intapp/soft/index/getstatus -安装软件,/intapp/soft/index/insert -启动软件,/intapp/soft/index/start -停止软件,/intapp/soft/index/stop -卸载软件,/intapp/soft/index/uninstall -gitssh公钥,/intapp/soft/index/gitssh -软件设置页面,/intapp/soft/page/soft - -frp服务端内容,/intapp/soft/frp/get_server -frp运行状态,/intapp/soft/frp/run_status -frp重启,/intapp/soft/frp/restart -frp停止,/intapp/soft/frp/stop -修改frp服务端配置,/intapp/soft/frp/upd_server -frp客户端内容,/intapp/soft/frp/get_client -修改frp客户端配置,/intapp/soft/frp/upd_client - -mongodb管理,/intapp/soft/mongodb - -获取mysql配置,/intapp/soft/mysql/get_data -修改mysql配置,/intapp/soft/mysql/upd_my -修改mysql密码,/intapp/soft/mysql/upd_data -备份mysql,/intapp/soft/mysql/backups - -nginx网站管理,/intapp/soft/page/s -修改nginx配置,/intapp/soft/nginx/index -nginx伪静态模板,/intapp/soft/nginx/anphp -nginx网站信息,/intapp/soft/nginx/webdescribesfind -nginx网站列表,/intapp/soft/nginx/weblist -添加更新nginx网站,/intapp/soft/nginx/add_web -删除nginx网站,/intapp/soft/nginx/del_web -获取ssl,/intapp/soft/nginx/getssl -获取伪静态内容,/intapp/soft/nginx/getrewr -获取配置文件,/intapp/soft/nginx/getconfig -证书夹,/intapp/soft/nginx/sslfolde -证书内容,/intapp/soft/nginx/ssltpl - -php管理,/intapp/soft/php - -redis管理,/intapp/soft/redis diff --git a/app/intapp/controller/soft/tpl/index/home.html b/app/intapp/controller/soft/tpl/index/home.html deleted file mode 100644 index cf08d1b..0000000 --- a/app/intapp/controller/soft/tpl/index/home.html +++ /dev/null @@ -1,428 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
-
- - - 搜索 - - - 更新软件列表 - -
-
- - % if config.app['appmode']=='develop': - - - - % endif - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - - - - - - - - - - - 如:/usr/local/php/ - - - - - - - - - - 注:需要在后端接口上配置wget文件地址 - - - - Linux - Windows - - - - - - -
- - - diff --git a/app/intapp/controller/soft/tpl/index/web.html b/app/intapp/controller/soft/tpl/index/web.html deleted file mode 100644 index a89e59e..0000000 --- a/app/intapp/controller/soft/tpl/index/web.html +++ /dev/null @@ -1,515 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
-
-    - - - 搜索 - 添加网站 - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
域名
端口 - 上传限制:MB
网站名
配置文件模板 - - - - -
备注
网站目录
-
- - - - - - - -
- - - - - - - 如:Access-Control-Allow-Origin * - 如:403 /403.html - - -
- 自定义配置:自定义响应或自定义错误页面 - -
- -
-
- - - - - - - - -
- - - - - - - - - -   - - -
- nginx负载均衡是一个代理均衡转发器 - -
- -
- - 取 消 - 修改添加 - -
- - -
-
- -
-
- 您已配置Let's证书


- ssl_certificate :{{admin.ssl_certificate}}

- ssl_certificate_key :{{admin.ssl_certificate_key}}

- 使用自有证书 -
-
-
- 密钥(KEY) - -
-
- 证书(PEM格式) - -
- 确定 -
-
-
- - -
- - - - - -
- 保存
- 选择伪静态模板就可以了,修改了记得要保存哦!重启nginx生效 -
- -
- - 确定 -
-
- -
- - - - - - - -
支持域名有效期
- - {{item1.domain}}     - - - - {{time_date(item.config.createtime+7776000,true)}} - - - - 使用 - -
-
-
-
- - - diff --git a/app/intapp/controller/soft/tpl/soft/frp.html b/app/intapp/controller/soft/tpl/soft/frp.html deleted file mode 100644 index c137b73..0000000 --- a/app/intapp/controller/soft/tpl/soft/frp.html +++ /dev/null @@ -1,250 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
- - - - - 重启 - 停止 - - 保存 - - - - - - -
- 重启 - 停止 - - - - 这是服端监听的地址 - - - - 这是服端监听的端口 - - - - 这是upd监听的端口 - - - - 这是kcp监听的端口 - - - - 这是http监听的端口 - - - - 这是https监听的端口 - - - - 这是dashboard监听的ip地址 - - - - 这是dashboard监听的端口 - - - - 这是dashboard监听的用户名 - - - - 这是dashboard监听的密码 - - - - 这是frp的验证机制 - - - - 这是frp的验证串的有效时间 - - - - - - - - 日志保持多少天 - - - - - - - - 白名单端口 - - - - 最大值进程数 - - - - - - - - - - - - - - - 保存 - - -
- -
- - - 保存 - -
-
-
-
- - - \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/git.html b/app/intapp/controller/soft/tpl/soft/git.html deleted file mode 100644 index ce87f2d..0000000 --- a/app/intapp/controller/soft/tpl/soft/git.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
-
- -
- 您可以使用root身份执行以下命令生成ssh密钥

- -
-
-
- - - \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/kodexplorer.html b/app/intapp/controller/soft/tpl/soft/kodexplorer.html deleted file mode 100644 index 6f38ff4..0000000 --- a/app/intapp/controller/soft/tpl/soft/kodexplorer.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - -
-
-
- - - - - - - - - - - - 添加 - -
-
-
- - - - \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/mongodb.html b/app/intapp/controller/soft/tpl/soft/mongodb.html deleted file mode 100644 index 417da13..0000000 --- a/app/intapp/controller/soft/tpl/soft/mongodb.html +++ /dev/null @@ -1,436 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
- - - -
- -

可以在终端中执行以下命令创建可以 -

- WORK_DIR=/data/mongodb
- mkdir -p $WORK_DIR/key/
- cd $WORK_DIR/key/
- openssl rand -base64 756 > mongo.key
- chmod 600 mongo.key
-
-

- 保存 -
-
- -
- config服务 (注:这是一个config服务) - - - - - - -
- 通常生产环境每台机器应该只有一个,您可以在其他机器上开启config服务后手动添加到副本集中
- -
- 运行中 - 停止服务 - 重启服务 -
-
- 已停止 - 启动服务 -
-
- 待初始化 - 初始化 -
-

-
- 副本集初始化(如果需要,生产环境应该是内网ip而不是127.0.0.1)
-
- -
-增加副本集示例 -
-mongo --port {{data.configs.server[0]['port']}}
-use admin
-rs.add({_id:1,host:'{{data.get_local_ip}}:27002',priority:2})#增加主机 priority:优先级
-
-删除副本集示例 -
-mongo --port {{data.configs.server[0]['port']}}
-use admin
-rs.remove('{{data.get_local_ip}}:27002')
-
-
- -
-
- -
- configdb: -
示例:configdb = configs/192.168.1.101:27001,192.168.1.102:27001,192.168.1.103:27001,则无法扩展外部服务器
- 上述ip和端口是已经启动的配置服务,可以是其他机器上的mongodb配置服务 -
- 路由服务 (注:这是一个路由服务) - - - - - - -
- -
-
- 运行中 - 停止服务 - 重启服务 -
-
- 已停止 - 启动服务 -
-
- 待初始化 - 初始化 -
-
-
- 初始化用户
-
- -
- 在路由中添加分片,如下示例
-
-mongo --port {{data.mongos.server[0]['port']}}
-use admin
-db.auth('admin','admin')
-sh.addShard("shard1/192.168.1.101:29001,192.168.1.102:29001") #shard1是分片集群id
-sh.status()
-
-
-
-
- -
-
- 分片服务名{{indexs+1}}: - - - - - - - -
- 通常生产环境每台机器应该只有一个,您可以在其他机器上开启分片服务后手动添加到副本集中
- -
- 运行中 - 停止服务 - 重启服务 -
-
- 已停止 - 启动服务 -
-
- 待初始化 - 初始化 -
-

-
- 副本集初始化(生产环境应该是内网ip而不是127.0.0.1)
- -
-
- -
-
-
- - - -
- - - - - - - - - - - - - -
绑定ip端口服务目录
- - 运行中 - 停止 - - - 已停止 - 启动 - - -
-
- - 保存 -
- -
-
- - - \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/mysql.html b/app/intapp/controller/soft/tpl/soft/mysql.html deleted file mode 100644 index ebeb98f..0000000 --- a/app/intapp/controller/soft/tpl/soft/mysql.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - 建议与mysql安装目录分开 - - 保存 - - - -
- - 保存 -
-
-
-
-
- - - \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/nginx.html b/app/intapp/controller/soft/tpl/soft/nginx.html deleted file mode 100644 index 8956ac7..0000000 --- a/app/intapp/controller/soft/tpl/soft/nginx.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
- - - - - - 保存 - 该配置文件只对该网站有效,修改后重启nginx生效
-
- -
- -
- - - - \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/php.html b/app/intapp/controller/soft/tpl/soft/php.html deleted file mode 100644 index f281a40..0000000 --- a/app/intapp/controller/soft/tpl/soft/php.html +++ /dev/null @@ -1,331 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
- - - -
- - - - - - - - - MB - - - 单个请求上传的文件的最大数量 - - - 秒 - - - 秒 - - - MB - - - MB - - - - - - 是否允许将url(如http://或 ftp://)作为文件处理。 - - - - - - 是否允许include/require以文件形式打开url(如http://或 ftp://)。 - - - - 基于套接字的流的默认超时(秒) - - - 保存 -
-
- -
- - - - - - - - - - 允许创建的最大子进程数 - - - - 起始进程数(服务启动后初始进程数量) - - - - 最小空闲进程数(清理空闲进程后的保留数量) - - - - 最大空闲进程数(当空闲进程达到此值时清理) - - - 保存 -
-
- -
- % if config.app['appmode']=='develop': - - % endif - - - - - - - - -
名称说明状态操作
{{item.title}}{{item.describes}} - % if config.app['appmode']=='develop': - {{item.filename}} - % endif - - - - - - 安装 - - - 等待下载 - - - 正在下载 - - - 正在安装 - - - 卸载 - - - 正在卸载... - - % if config.app['appmode']=='develop': - 删除 - % endif -
-
-
- - - - - 保存 - 该配置文件只对{{data.php.title}}有效,修改后重启{{data.php.title}}生效
-
- - - - 保存 - 该配置文件只对{{data.php.title}}有效,修改后重启{{data.php.title}}生效
-
-
- - - - - - - - - - - - - - - - - - - 添加 - -
- - - \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/phpmyadmin.html b/app/intapp/controller/soft/tpl/soft/phpmyadmin.html deleted file mode 100644 index 053916a..0000000 --- a/app/intapp/controller/soft/tpl/soft/phpmyadmin.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - -
-
-
- - - - - - - - - - - - 添加 - -
-
-
- - - - \ No newline at end of file diff --git a/app/intapp/controller/soft/tpl/soft/redis.html b/app/intapp/controller/soft/tpl/soft/redis.html deleted file mode 100644 index 64eac89..0000000 --- a/app/intapp/controller/soft/tpl/soft/redis.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
- - -
- - - 绑定IP - - - 端口 - - - 空闲连接超时时间,0表示不断开 - - - 最大连接数 - - - 数据库数量 - - - redis密码,留空代表没有设置密码 - - - MB,最大使用内存,0表示不限制 - - - 保存 -
-
- - - - - 保存 - 修改后重启redis生效
-
-
-
- - - \ No newline at end of file -- Gitee From 1ca70b0e63e446214d478aceaf734b7f98079211 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 04:40:41 +0800 Subject: [PATCH 039/202] kun --- kcweb/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kcweb/app.py b/kcweb/app.py index c80d618..9615abe 100644 --- a/kcweb/app.py +++ b/kcweb/app.py @@ -215,6 +215,8 @@ class web: modular=web.__get_modular(self,header) if route['plug']: getplug=web.__get_plug(self,header) + else: + getplug='' routedefault=route['default'] methods=route['methods'] if routedefault: -- Gitee From 0d96b53932259ce2b173f6c27195ab2287f5a015 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 04:42:55 +0800 Subject: [PATCH 040/202] kun --- app/config/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/config/app.py b/app/config/app.py index 8b4b60b..cb0d970 100644 --- a/app/config/app.py +++ b/app/config/app.py @@ -43,8 +43,8 @@ mongo['retryWrites']=False #是否支持重新写入 #路由配置 route['default']=True #是否开启默认路由 默认路由开启后面不影响以下配置的路由,模块名/版本名/控制器文件名/方法名 作为路由地址 如:http://www.kcw.com/modular/plug/index/index/ -route['modular']=[{"192":"website"},{"www":"website"}] #指定访问配置固定模块 (如果匹配了该值,将无法通过改变url访问不同模块) -route['plug']=[{"192":"index"},{"www":"index"}] #指定访问固定插件 (如果匹配了该值,将无法通过改变url访问不同插件) +route['modular']="" #指定访问配置固定模块 (如果匹配了该值,将无法通过改变url访问不同模块) +route['plug']="" #指定访问固定插件 (如果匹配了该值,将无法通过改变url访问不同插件) route['defmodular']='intapp' #默认模块 当url不包括模块名时 route['defplug']='index' #默认插件 当url不包括插件名时 route['files']='index' #默认路由文件(控制器) 当url不包括控制器名时 -- Gitee From 533f9a254dfbbda99325481397397d641fed2ba7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 25 Aug 2020 10:51:42 +0800 Subject: [PATCH 041/202] kun --- kcweb/utill/db/mysql.py | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/kcweb/utill/db/mysql.py b/kcweb/utill/db/mysql.py index 52f1f8d..8c8aec4 100644 --- a/kcweb/utill/db/mysql.py +++ b/kcweb/utill/db/mysql.py @@ -37,7 +37,7 @@ class mysql: elif isinstance(mysql.__conn,dict): i=0 for thost in self.__config['host']: - identifier=thost+str(self.__config['port'][i])+self.__config['user'][i]+self.__config['password'][i]+self.__config['db'][i] + identifier=thost+str(self.__config['port'][i])+self.__config['user'][i]+self.__config['password'][i] print(mysql.__conn) for k in mysql.__conn[identifier]: try: @@ -98,7 +98,7 @@ class mysql: try: if self.__config['deploy']==0: # 集中式(单一服务器) if self.__config['pattern']: # 长连接情况下 - self.__masteridentifier=self.__config['host'][0]+str(self.__config['port'][0])+self.__config['user'][0]+self.__config['password'][0]+self.__config['db'][0] # 服务器标识 + self.__masteridentifier=self.__config['host'][0]+str(self.__config['port'][0])+self.__config['user'][0]+self.__config['password'][0] # 服务器标识 if self.__masteridentifier not in mysql.__conn or len(mysql.__conn[self.__masteridentifier])<1: i=0 masterlistsdb=[] @@ -111,7 +111,7 @@ class mysql: if self.__config['debug']: print("第%s次创建数据库链接对象,长连接模式" % (self.__errorcounts+1)) else: - self.__masteridentifier=self.__config['host'][0]+str(self.__config['port'][0])+self.__config['user'][0]+self.__config['password'][0]+self.__config['db'][0] # 服务器标识 + self.__masteridentifier=self.__config['host'][0]+str(self.__config['port'][0])+self.__config['user'][0]+self.__config['password'][0] # 服务器标识 try: mysql.__conn[self.__masteridentifier] except KeyError: # 铺获未知异常 @@ -124,12 +124,12 @@ class mysql: j=0 self.__masteridentifier='' while j < self.__config['master_num']: - self.__masteridentifier=self.__masteridentifier+self.__config['host'][j]+str(self.__config['port'][j])+self.__config['user'][j]+self.__config['password'][j]+self.__config['db'][j] # 主服务器标识 + self.__masteridentifier=self.__masteridentifier+self.__config['host'][j]+str(self.__config['port'][j])+self.__config['user'][j]+self.__config['password'][j] # 主服务器标识 j=j+1 j=self.__config['master_num'] self.__slaveidentifier='' while j < self.__dbcount: - self.__slaveidentifier=self.__slaveidentifier+self.__config['host'][j]+str(self.__config['port'][j])+self.__config['user'][j]+self.__config['password'][j]+self.__config['db'][j] # 从服务器标识 + self.__slaveidentifier=self.__slaveidentifier+self.__config['host'][j]+str(self.__config['port'][j])+self.__config['user'][j]+self.__config['password'][j] # 从服务器标识 j=j+1 if self.__masteridentifier not in mysql.__conn or len(mysql.__conn[self.__masteridentifier])1: + return len(result) + else: + cou=int(result[0][0]) + return cou def max(self,field): """查询某字段的最大值 @@ -761,6 +764,9 @@ class mysql: 参数 length:int 查询数量 """ + offset=int(offset) + if length: + length=int(length) self.__limit=[offset,length] return self def page(self,pagenow=1, length = 20): @@ -770,6 +776,8 @@ class mysql: 参数 length:int 查询数量 """ + pagenow=int(pagenow) + length=int(length) offset=(pagenow-1)*length self.__limit=[offset,length] return self @@ -961,6 +969,12 @@ class mysql: self.__sql=self.__sql + " WHERE %s" % self.__listTrans() else: print("参数where类型错误") + if self.__group: + s=self.__group + if self.__group1: + for key in self.__group1: + s=s+","+key + self.__sql=self.__sql+" GROUP BY "+s if self.__order: s='' if isinstance(self.__order,list): @@ -994,12 +1008,6 @@ class mysql: else: s=self.__order self.__sql=self.__sql+" ORDER BY "+s - if self.__group: - s=self.__group - if self.__group1: - for key in self.__group1: - s=s+","+key - self.__sql=self.__sql+" GROUP BY "+s if self.__having: self.__sql=self.__sql+" HAVING "+self.__having if self.__limit: -- Gitee From a1e6c77a19b4b647d83b53079e83fd5b88cc0138 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 25 Aug 2020 13:07:29 +0800 Subject: [PATCH 042/202] kun --- kcweb/utill/db/mysql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcweb/utill/db/mysql.py b/kcweb/utill/db/mysql.py index 8c8aec4..b59dd57 100644 --- a/kcweb/utill/db/mysql.py +++ b/kcweb/utill/db/mysql.py @@ -1071,4 +1071,4 @@ class mysql: k='LIKE' else: k=strss - return k \ No newline at end of file + return k \ No newline at end of file -- Gitee From f453ac41b3a4f08f886ad6754398b7aff2e011ab Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 25 Aug 2020 13:07:36 +0800 Subject: [PATCH 043/202] kun --- kcweb/utill/db/mysql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcweb/utill/db/mysql.py b/kcweb/utill/db/mysql.py index b59dd57..8c8aec4 100644 --- a/kcweb/utill/db/mysql.py +++ b/kcweb/utill/db/mysql.py @@ -1071,4 +1071,4 @@ class mysql: k='LIKE' else: k=strss - return k \ No newline at end of file + return k \ No newline at end of file -- Gitee From d2f79a430f56ce06afad25f8d9af3fdc6dbb7b11 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 25 Aug 2020 13:08:55 +0800 Subject: [PATCH 044/202] kun --- kcweb/utill/db/mysql.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kcweb/utill/db/mysql.py b/kcweb/utill/db/mysql.py index 8c8aec4..9374dca 100644 --- a/kcweb/utill/db/mysql.py +++ b/kcweb/utill/db/mysql.py @@ -37,7 +37,7 @@ class mysql: elif isinstance(mysql.__conn,dict): i=0 for thost in self.__config['host']: - identifier=thost+str(self.__config['port'][i])+self.__config['user'][i]+self.__config['password'][i] + identifier=thost+str(self.__config['port'][i])+self.__config['user'][i]+self.__config['password'][i]+self.__config['db'][i] print(mysql.__conn) for k in mysql.__conn[identifier]: try: @@ -98,7 +98,7 @@ class mysql: try: if self.__config['deploy']==0: # 集中式(单一服务器) if self.__config['pattern']: # 长连接情况下 - self.__masteridentifier=self.__config['host'][0]+str(self.__config['port'][0])+self.__config['user'][0]+self.__config['password'][0] # 服务器标识 + self.__masteridentifier=self.__config['host'][0]+str(self.__config['port'][0])+self.__config['user'][0]+self.__config['password'][0]+self.__config['db'][0] # 服务器标识 if self.__masteridentifier not in mysql.__conn or len(mysql.__conn[self.__masteridentifier])<1: i=0 masterlistsdb=[] @@ -111,7 +111,7 @@ class mysql: if self.__config['debug']: print("第%s次创建数据库链接对象,长连接模式" % (self.__errorcounts+1)) else: - self.__masteridentifier=self.__config['host'][0]+str(self.__config['port'][0])+self.__config['user'][0]+self.__config['password'][0] # 服务器标识 + self.__masteridentifier=self.__config['host'][0]+str(self.__config['port'][0])+self.__config['user'][0]+self.__config['password'][0]+self.__config['db'][0] # 服务器标识 try: mysql.__conn[self.__masteridentifier] except KeyError: # 铺获未知异常 @@ -124,12 +124,12 @@ class mysql: j=0 self.__masteridentifier='' while j < self.__config['master_num']: - self.__masteridentifier=self.__masteridentifier+self.__config['host'][j]+str(self.__config['port'][j])+self.__config['user'][j]+self.__config['password'][j] # 主服务器标识 + self.__masteridentifier=self.__masteridentifier+self.__config['host'][j]+str(self.__config['port'][j])+self.__config['user'][j]+self.__config['password'][j]+self.__config['db'][j] # 主服务器标识 j=j+1 j=self.__config['master_num'] self.__slaveidentifier='' while j < self.__dbcount: - self.__slaveidentifier=self.__slaveidentifier+self.__config['host'][j]+str(self.__config['port'][j])+self.__config['user'][j]+self.__config['password'][j] # 从服务器标识 + self.__slaveidentifier=self.__slaveidentifier+self.__config['host'][j]+str(self.__config['port'][j])+self.__config['user'][j]+self.__config['password'][j]+self.__config['db'][j] # 从服务器标识 j=j+1 if self.__masteridentifier not in mysql.__conn or len(mysql.__conn[self.__masteridentifier]) Date: Tue, 25 Aug 2020 15:32:52 +0800 Subject: [PATCH 045/202] kun --- app/common/__init__.py | 6 +- app/intapp/controller/index/role.txt | 21 +- app/intapp/controller/index/setup.py | 46 ++- .../controller/index/tpl/index/index.html | 9 +- .../controller/index/tpl/menu/index.html | 2 +- .../controller/index/tpl/plan/index.html | 12 +- .../index/tpl/setup/bacrecpage.html | 215 +++++++++++ .../controller/index/tpl/setup/basepage.html | 101 ++++++ .../index/tpl/setup/index copy.html | 334 ++++++++++++++++++ .../controller/index/tpl/setup/index.html | 316 +++-------------- .../controller/index/tpl/setup/startpage.html | 137 +++++++ app/static/js/function.js | 2 +- 12 files changed, 896 insertions(+), 305 deletions(-) create mode 100644 app/intapp/controller/index/tpl/setup/bacrecpage.html create mode 100644 app/intapp/controller/index/tpl/setup/basepage.html create mode 100644 app/intapp/controller/index/tpl/setup/index copy.html create mode 100644 app/intapp/controller/index/tpl/setup/startpage.html diff --git a/app/common/__init__.py b/app/common/__init__.py index adf8e5e..91f4e8a 100644 --- a/app/common/__init__.py +++ b/app/common/__init__.py @@ -41,11 +41,11 @@ def serlogin(username,sign,timestamp,random,types="session"): {'title':'首页','icon':config.domain['kcwebimg']+'/icon/home.png','url':'/intapp/index/index/home',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, {'title':'管理员','icon':config.domain['kcwebimg']+'/icon/admin.png','url':'/intapp/index/admin',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, # {'title':'终端管理','icon':config.domain['kcwebimg']+'/icon/terminal.png','url':'/intapp/index/socket/terminallist',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, - {'title':'导航管理','icon':config.domain['kcwebimg']+'/icon/menu.png','url':'/intapp/index/menu',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, + # {'title':'导航管理','icon':config.domain['kcwebimg']+'/icon/menu.png','url':'/intapp/index/menu',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, {'title':'模块管理','icon':config.domain['kcwebimg']+'/icon/modular.png','url':'/intapp/index/modular',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, {'title':'插件管理','icon':config.domain['kcwebimg']+'/icon/plug.png','url':'/intapp/index/plug',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, - {'title':'计划任务','icon':config.domain['kcwebimg']+'/icon/plan.png','url':'/intapp/index/plan',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, - {'title':'任务队列','icon':config.domain['kcwebimg']+'/icon/task.png','url':'/intapp/index/task',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, + # {'title':'计划任务','icon':config.domain['kcwebimg']+'/icon/plan.png','url':'/intapp/index/plan',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, + # {'title':'任务队列','icon':config.domain['kcwebimg']+'/icon/task.png','url':'/intapp/index/task',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000}, {'title':'系统配置','icon':config.domain['kcwebimg']+'/icon/setup.png','url':'/intapp/index/setup',"types":"left","pid":0,"admin_id":inifo['id'],"sort":10000} ] plugmenu=sqlite('plug',model_app_path).select() diff --git a/app/intapp/controller/index/role.txt b/app/intapp/controller/index/role.txt index 9707eaa..ae1325f 100644 --- a/app/intapp/controller/index/role.txt +++ b/app/intapp/controller/index/role.txt @@ -50,21 +50,22 @@ shell执行能力,/intapp/index/index/shell 添加计划,/intapp/index/plan/add 删除计划,/intapp/index/plan/delpl 计划日志,/intapp/index/plan/log -保存计划配置,/intapp/index/plan/setconfig 任务页面,/intapp/index/task/index 任务列表,/intapp/index/task/task 任务状态,/intapp/index/task/taskstatus -设置页面,/intapp/index/setup/index +设置,/intapp/index/setup/index +基本配置,/intapp/index/setup/basepage +开机启动项,/intapp/index/setup/startpage +备份恢复,/intapp/index/setup/bacrecpage +获取/保存配置信息,/intapp/index/setup/setbaseconfig 添加启动项,/intapp/index/setup/addstart 删除启动项,/intapp/index/setup/delstart -列出启动项,/intapp/index/setup/startlist -备份全部,/intapp/index/setup/backup +获取启动项,/intapp/index/setup/startlist +阿里云备份列表,/intapp/index/setup/aliyunosslist +阿里云备点恢复,/intapp/index/setup/aliyunossdownload +备份全部文稿,/intapp/index/setup/backup 恢复全部文稿,/intapp/index/setup/recovery -下载备份,/intapp/index/setup/download -上传备份,/intapp/index/setup/postsup -保存配置信息,/intapp/index/setup/setconfig -阿里云列表,/intapp/index/setup/aliyunosslist -从阿里云备份点恢复,/intapp/index/setup/aliyunossdownload - +下载备份文件,/intapp/index/setup/download +上传备份文件,/intapp/index/setup/postsup diff --git a/app/intapp/controller/index/setup.py b/app/intapp/controller/index/setup.py index fd05757..6d8aa15 100644 --- a/app/intapp/controller/index/setup.py +++ b/app/intapp/controller/index/setup.py @@ -2,6 +2,31 @@ from .common import * import base64,oss2 def index(): return response.tpl() +def basepage(): + "基本配置" + return response.tpl() +def startpage(): + "开机启动项" + return response.tpl() +def bacrecpage(): + "备份恢复页面" + return response.tpl() + +def setbaseconfig(types='get'): + "保存配置信息" + if types=='get': + if os.path.isfile("app/common/file/config.conf"): + data=json_decode(file_get_content("app/common/file/config.conf")) + if not data['aliyun']['backpath']: + data['aliyun']['backpath']="kcweb" + else: + data={} + return successjson(data) + else: + config=request.get_json() + file_set_content("app/common/file/config.conf",json_encode(config)) + return successjson(msg="保存成功") + def addstart(): "添加启动项" data=request.get_json() @@ -33,24 +58,19 @@ def startlist(): lists=yz[0] count=yz[1] data=return_list(lists,count,pagenow,pagesize) - if os.path.isfile("app/common/file/config.conf"): - data['config']=json_decode(file_get_content("app/common/file/config.conf")) - if not data['config']['aliyun']['backpath']: - data['config']['aliyun']['backpath']="kcweb" - else: - data['config']={} + return successjson(data) -def setconfig(): - "保存配置信息" - config=request.get_json() - file_set_content("app/common/file/config.conf",json_encode(config)) - return successjson() -def aliyunosslist(): + +def aliyunosslist(types='app'): if not os.path.isfile("app/common/file/config.conf"): return errorjson(msg="请先配置阿里云oss配置信息") + data=json_decode(file_get_content("app/common/file/config.conf")) prefix=request.args.get("prefix") if not prefix: - prefix="backups/" + if types=='types': + prefix="backups/"+data['aliyun']['backpath']+"/app/" + else: + prefix="backups/"+data['aliyun']['backpath']+"/backup/mysql/" data=[] try: fileconfig=json_decode(file_get_content("app/common/file/config.conf")) diff --git a/app/intapp/controller/index/tpl/index/index.html b/app/intapp/controller/index/tpl/index/index.html index 3b21db2..e6c4195 100644 --- a/app/intapp/controller/index/tpl/index/index.html +++ b/app/intapp/controller/index/tpl/index/index.html @@ -27,7 +27,14 @@ .kcw-side-scroll::-webkit-scrollbar-track {border-radius: 0px;} .kcw-side-scroll::-webkit-scrollbar-thumb {border-radius: 10px;background-image: linear-gradient(135deg, #1DE9B6 0%, rgba(8, 196, 219, 1) 72%, #057494 100%);transition: all .2s;} .el-header, .el-footer {background-color: #B3C0D1;line-height: 60px;padding:0px;} - +.el-menu-item, .el-submenu__title { + height: 45px; + line-height: 40px; + position: relative; + -webkit-box-sizing: border-box; + white-space: nowrap; + list-style: none; +} diff --git a/app/intapp/controller/index/tpl/menu/index.html b/app/intapp/controller/index/tpl/menu/index.html index 4182807..f5c5f40 100644 --- a/app/intapp/controller/index/tpl/menu/index.html +++ b/app/intapp/controller/index/tpl/menu/index.html @@ -140,7 +140,7 @@ var vm = new Vue({ }, getlist:function(){ self=this - self.get("/intapp/index/menu/menulist/"+self.admin.pid,{'kw':self.kw,'pagesize':self.data.pagesize,'pagenow':self.data.pagenow},'获取中...').then(function(res){ + self.get("/intapp/index/menu/menulist/"+self.admin.pid,{'kw':self.kw,'pagesize':self.data.pagesize,'pagenow':self.data.pagenow}).then(function(res){ if(self.admin.pid && !res.data.count){ self.admin.pid=0;self.pid=0; self.$message({type: 'success',message: '暂无数据'}); diff --git a/app/intapp/controller/index/tpl/plan/index.html b/app/intapp/controller/index/tpl/plan/index.html index 117ebe3..bc7a1df 100644 --- a/app/intapp/controller/index/tpl/plan/index.html +++ b/app/intapp/controller/index/tpl/plan/index.html @@ -291,12 +291,12 @@ var vm = new Vue({ }) }) }, - setconfig:function(path){ - self=this - self.post("/intapp/index/plan/setconfig/set/"+path,self.strconfig,'保存中...').then(function(res){ - self.$message({type: 'success',message:res.msg}); - }) - }, + // setconfig:function(path){ + // self=this + // self.post("/intapp/index/plan/setconfig/set/"+path,self.strconfig,'保存中...').then(function(res){ + // self.$message({type: 'success',message:res.msg}); + // }) + // }, getlog:function(iden){ self=this self.get("/intapp/index/plan/log/"+iden,null,'获取中...').then(function(res){ diff --git a/app/intapp/controller/index/tpl/setup/bacrecpage.html b/app/intapp/controller/index/tpl/setup/bacrecpage.html new file mode 100644 index 0000000..01b5cae --- /dev/null +++ b/app/intapp/controller/index/tpl/setup/bacrecpage.html @@ -0,0 +1,215 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+
+
+
+ 备份所有 + 恢复所有 + 下载备份文件 +
+
+ + +
将备份文件拖到此处,或点击上传
+
只能上传压缩包zip文件
+
+
+
+
+

阿里云oss文稿备份点

+ + + + + + + + +
+
+

阿里云oss mysql备份点

+ + + + + + + + +
+
+
+ + + \ No newline at end of file diff --git a/app/intapp/controller/index/tpl/setup/basepage.html b/app/intapp/controller/index/tpl/setup/basepage.html new file mode 100644 index 0000000..9506f0c --- /dev/null +++ b/app/intapp/controller/index/tpl/setup/basepage.html @@ -0,0 +1,101 @@ + + + + + +基本配置 + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + 保存 + + +
+
+ + + \ No newline at end of file diff --git a/app/intapp/controller/index/tpl/setup/index copy.html b/app/intapp/controller/index/tpl/setup/index copy.html new file mode 100644 index 0000000..2355ec3 --- /dev/null +++ b/app/intapp/controller/index/tpl/setup/index copy.html @@ -0,0 +1,334 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+
+ + +
+    + + 添加启动项 + +
+ + + + + + + + + + + + + +
+ +
+
+ 备份所有 + 恢复所有 + 下载备份文件 +
+
+ + +
将备份文件拖到此处,或点击上传
+
只能上传压缩包zip文件
+
+
+
+
+

阿里云oss文稿备份点

+ + + + + + + + +
+
+

阿里云oss mysql备份点

+ + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + 保存 + + + + +
+ + + + + + + + + + + 取 消 + 添加 + + +
+
+ + + \ No newline at end of file diff --git a/app/intapp/controller/index/tpl/setup/index.html b/app/intapp/controller/index/tpl/setup/index.html index 2355ec3..4fe31a6 100644 --- a/app/intapp/controller/index/tpl/setup/index.html +++ b/app/intapp/controller/index/tpl/setup/index.html @@ -34,133 +34,26 @@
-
- - -
-    - - 添加启动项 - + + 基本配置 + 开机启动项 + 备份恢复 + 计划任务 + 导航管理 + 任务队列 + +
+ +
+
- - - - - - - - - - - - - - - -
-
- 备份所有 - 恢复所有 - 下载备份文件 -
-
- - -
将备份文件拖到此处,或点击上传
-
只能上传压缩包zip文件
-
-
+ + +
+
-
-

阿里云oss文稿备份点

- - - - - - - - -
-
-

阿里云oss mysql备份点

- - - - - - - - -
- - - - - - - - - - - - - - - - - - - - 保存 - - - - - - - - - - - - - - - - 取 消 - 添加 - - -
+
+
diff --git a/app/intapp/controller/index/tpl/setup/startpage.html b/app/intapp/controller/index/tpl/setup/startpage.html new file mode 100644 index 0000000..6ae60e7 --- /dev/null +++ b/app/intapp/controller/index/tpl/setup/startpage.html @@ -0,0 +1,137 @@ + + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+
+
+    + + 添加启动项 + +
+ + + + + + + + + + + + + + + + + + + + + + + + 取 消 + 添加 + + +
+
+ + + \ No newline at end of file diff --git a/app/static/js/function.js b/app/static/js/function.js index 9df98f7..cc2bb68 100644 --- a/app/static/js/function.js +++ b/app/static/js/function.js @@ -52,7 +52,7 @@ axios_instance.interceptors.response.use(function(res){ Vue.prototype.get=function(url,params,text){ self=this if(text){//self.$message({message: text,type: 'error'}); - var Loading = self.$loading({lock: true,text: text,spinner: 'el-icon-loading',background: 'rgba(0, 0, 0, 1)'}); + var Loading = self.$loading({lock: true,text: text,spinner: 'el-icon-loading',background: 'rgba(0, 0, 0, 0.7)'}); } return new Promise(function(resolve,reject){ axios_instance.get(url,{params:params}) -- Gitee From ad1b8f66c7079fde7e1b1076056a083abcc202c2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 25 Aug 2020 19:11:06 +0800 Subject: [PATCH 046/202] kun --- app/intapp/controller/__init__.py | 3 +- app/intapp/controller/file/__init__.py | 1 + app/intapp/controller/file/common/__init__.py | 2 + app/intapp/controller/file/common/autoload.py | 1 + .../file/common/file/sqlite/.gitignore | 1 + app/intapp/controller/file/common/model.py | 4 + app/intapp/controller/file/index.py | 234 +++++++++ app/intapp/controller/file/install.txt | 1 + app/intapp/controller/file/role.txt | 15 + app/intapp/controller/file/tpl/index/ace.html | 135 ++++++ .../controller/file/tpl/index/folderace.html | 194 ++++++++ .../controller/file/tpl/index/index.html | 452 ++++++++++++++++++ app/intapp/controller/index/admin.py | 5 +- app/intapp/controller/index/common/model.py | 41 +- app/intapp/controller/index/setup.py | 38 +- .../controller/index/tpl/admin/index.html | 13 +- .../controller/index/tpl/setup/index.html | 2 + .../controller/index/tpl/setup/run.html | 232 +++++++++ 18 files changed, 1347 insertions(+), 27 deletions(-) create mode 100644 app/intapp/controller/file/__init__.py create mode 100644 app/intapp/controller/file/common/__init__.py create mode 100644 app/intapp/controller/file/common/autoload.py create mode 100644 app/intapp/controller/file/common/file/sqlite/.gitignore create mode 100644 app/intapp/controller/file/common/model.py create mode 100644 app/intapp/controller/file/index.py create mode 100644 app/intapp/controller/file/install.txt create mode 100644 app/intapp/controller/file/role.txt create mode 100644 app/intapp/controller/file/tpl/index/ace.html create mode 100644 app/intapp/controller/file/tpl/index/folderace.html create mode 100644 app/intapp/controller/file/tpl/index/index.html create mode 100644 app/intapp/controller/index/tpl/setup/run.html diff --git a/app/intapp/controller/__init__.py b/app/intapp/controller/__init__.py index 6a03892..16446a2 100644 --- a/app/intapp/controller/__init__.py +++ b/app/intapp/controller/__init__.py @@ -1,2 +1,3 @@ -from . import index \ No newline at end of file +from . import index +from . import file \ No newline at end of file diff --git a/app/intapp/controller/file/__init__.py b/app/intapp/controller/file/__init__.py new file mode 100644 index 0000000..3471b9b --- /dev/null +++ b/app/intapp/controller/file/__init__.py @@ -0,0 +1 @@ +from . import index \ No newline at end of file diff --git a/app/intapp/controller/file/common/__init__.py b/app/intapp/controller/file/common/__init__.py new file mode 100644 index 0000000..60767ac --- /dev/null +++ b/app/intapp/controller/file/common/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from .model import * \ No newline at end of file diff --git a/app/intapp/controller/file/common/autoload.py b/app/intapp/controller/file/common/autoload.py new file mode 100644 index 0000000..eb780f3 --- /dev/null +++ b/app/intapp/controller/file/common/autoload.py @@ -0,0 +1 @@ +from app.intapp.common import * \ No newline at end of file diff --git a/app/intapp/controller/file/common/file/sqlite/.gitignore b/app/intapp/controller/file/common/file/sqlite/.gitignore new file mode 100644 index 0000000..72a3e83 --- /dev/null +++ b/app/intapp/controller/file/common/file/sqlite/.gitignore @@ -0,0 +1 @@ +intappindex \ No newline at end of file diff --git a/app/intapp/controller/file/common/model.py b/app/intapp/controller/file/common/model.py new file mode 100644 index 0000000..fe6e8f6 --- /dev/null +++ b/app/intapp/controller/file/common/model.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from .autoload import * +# 可以在这里初始化数据库 +model_intapp_file_path=os.path.split(os.path.realpath(__file__))[0]+"/file/sqlite/intappindex" #数据存放目录 diff --git a/app/intapp/controller/file/index.py b/app/intapp/controller/file/index.py new file mode 100644 index 0000000..75f9dc0 --- /dev/null +++ b/app/intapp/controller/file/index.py @@ -0,0 +1,234 @@ +from .common import * +import psutil +def index(): + paths=request.args.get("paths") + select=request.args.get("select") + if not paths: + paths="" + if not select: + select=0 + return response.tpl(paths=paths,systype=get_sysinfo()['platform'],select=select) +def ace(): + "编辑器页面 单文件" + filename=request.args.get('filename') + theme,mode=__get_theme_mode(filename) + return response.tpl(filename=filename,content='',theme=theme,mode=mode) +def folderace(): + "编辑器页面 文件夹" + paths=request.args.get('paths') + name=request.args.get('name') + return response.tpl(paths=paths,name=name,content='',theme='solarized_light',mode='html') +def __get_theme_mode(filename): + hz=filename.split('.')[-1] + theme='solarized_dark' ##chaos xcode + mode='io' + hz=filename.split('.')[-1] + if 'py'==hz or 'pyc'==hz: + theme="chaos" + mode='python' + elif 'php'==hz: + theme="solarized_light" + mode='php' + elif 'js'==hz: + theme="chaos" + mode='javascript' + elif 'java'==hz: + theme="chaos" + mode='java' + elif 'sh'==hz: + theme="tomorrow_night_blue" + mode='gcode' + elif 'html'==hz or 'shtml'==hz or 'htm'==hz: + mode='html' + elif 'ini'==hz or 'conf'==hz or 'config'==hz: + mode='html' + elif 'json'==hz: + mode='json' + return theme,mode +def savefile(): + "保存文件内容" + data=request.get_json() + filename=data['filename'] + content=data['content'] + encoding=data['encoding'] + file_set_content(filename,content,encoding=encoding) + return successjson() +def getfile(): + "获取文件内容" + filename=request.args.get('filename') + content,encoding=file_get_content(filename,True) + theme,mode=__get_theme_mode(filename) + return successjson({"content":content,"encoding":encoding,"theme":theme,'mode':mode}) +def disk():#磁盘分区和使用情况 + partition=[] + disk_usage=psutil.disk_usage('/') + if "Linux" in get_sysinfo()['platform']: + partition.append({ + 'name':'/','src':'分区 /',"suffix":'','types':'disk','count':disk_usage[0],'used':disk_usage[1],'free':disk_usage[2],'userate':disk_usage[3] + }) + partitions=psutil.disk_partitions() + for v in partitions: + disk_usage=psutil.disk_usage(v[0]) + if disk_usage[0]: + if "Windows" in get_sysinfo()['platform']: + partition.append({ + 'name':v[0][0:2]+"/","src":"本地磁盘 ("+v[0][0]+")","suffix":'','types':v[2],'count':disk_usage[0],'used':disk_usage[1],'free':disk_usage[2],'userate':disk_usage[3] + }) + elif "Linux" in get_sysinfo()['platform']: + partition.append({ + 'name':v[0],"src":"分区 ("+v[0]+")","suffix":'','types':v[2],'count':disk_usage[0],'used':disk_usage[1],'free':disk_usage[2],'userate':disk_usage[3] + }) + return successjson(partition) +def lists(): + "文件列表" + paths=request.args.get('paths') + kw=request.args.get('kw') + if not paths: + paths=os.path.abspath('.')+"/" + paths=paths.replace("\\", "/") + if paths[-1] != '/': + paths+="/" + if not os.path.exists(paths): + return errorjson(code=1,msg="文件夹不存在") + try: + lis=os.listdir(paths) + except: + return errorjson(code=1,msg="无法打开"+str(paths)) + lists=[] + filelist=[] + folderlist=[] + for files in lis: + if kw: + if kw in files: + if os.path.isfile(paths+files): + zd={"name":files,"src":files,"types":'file','suffix':files.split('.')[-1]} + filelist.append(zd) + elif os.path.exists(paths+files): + zd={"name":files,"src":files,"types":'folder','suffix':''} + folderlist.append(zd) + else: + zd={"name":files,"src":files,"types":'other','suffix':''} + filelist.append(zd) + else: + if os.path.isfile(paths+files): + zd={"name":files,"src":files,"types":'file','suffix':files.split('.')[-1]} + filelist.append(zd) + elif os.path.exists(paths+files): + zd={"name":files,"src":files,"types":'folder','suffix':''} + folderlist.append(zd) + else: + zd={"name":files,"src":files,"types":'other','suffix':''} + filelist.append(zd) + lists=folderlist+filelist + if lists: + data=return_list(lists,count=len(lis),pagenow=1,pagesize=1) + else: + data=return_list(lists,count=0,pagenow=1,pagesize=1) + data['paths']=paths + pathss=paths.split('/') + for i in pathss: + if i=='': + pathss.remove(i) + data['pathss']=pathss + "文件列表" + return successjson(data) +def uploadfile(): + paths=request.args.get('paths') + "上传文件" + if request.binary.save('file',paths+request.binary.filename('file')): + return successjson() + else: + return errorjson(msg="上传失败") +def delfile(): + "删除文件" + data=request.get_json() + paths=data['paths'] + lists=data['lists'] + for k in lists: + if k['types']=='file': #删除文件 + if os.path.isfile(paths+k['name']): + os.remove(paths+k['name']) + else: #删除文件夹 + shutil.rmtree(paths+k['name']) + return successjson(data) +def setname(): + "重命名和创建文件夹" + data=request.get_json() + paths=data['paths'] + src=data['src'] + dst=data['dst'] + if os.path.exists(paths+src): + if src != dst: #重命名文件夹 + os.rename(paths+src,paths+dst) + else: #创建文件夹 + if not os.path.exists(paths+dst): + os.makedirs(paths+dst) + else: + return errorjson(msg="该文件夹已存在") + return successjson() +def compress(types='zip'): + "压缩" + pathfile=request.args.get("pathfile") + if pathfile[-1]=='/': + filename=pathfile[:-1]+"."+types + else: + filename=pathfile+"."+types + if types=='zip': + zip.packzip(pathfile,filename) + elif types=='tar': + kcwtar.targz(pathfile,filename) + return successjson() +def decomp(types='zip'): + "解压" + filename=request.args.get("filename") + pathfilearr=filename.split(".") + pathfile='' + i=0 + while True: + if i>= (len(pathfilearr)-1): + break + else: + pathfile+=pathfilearr[i] + i+=1 + if types=='zip': + zip.unzip_file(filename,pathfile) + elif types=='tar': + kcwtar.untar(filename,pathfile) + else: + try: + zip.unzip_file(filename,pathfile) + except: + try: + kcwtar.untar(filename,pathfile) + except: + return errorjson("无法解压该压缩包") + return successjson() +def download(name): + "下载文件" + pathname=request.args.get("pathname") + return response.download(pathname) +def paste(): + "复制/移动文件" + copy=request.get_json() + pathname=copy['paths'] + dsc=copy['dsc'] + if os.path.isfile(pathname) or os.path.exists(pathname): + dsc+=pathname.split("/")[-1] + if os.path.exists(dsc): + dsc+=" copy" + if copy['types']=='copy': #复制 + if os.path.isfile(pathname): + shutil.copyfile(pathname,dsc) + else: + shutil.copytree(pathname,dsc) + elif copy['types']=='shear': #移动 + shutil.move(pathname,dsc) + else: + return errorjson("类型错误") + else: + return errorjson("您选择的文件不存在") + return successjson() +def getimg(): + "显示图片" + filename=request.args.get('filename') + return response.pic(filename) \ No newline at end of file diff --git a/app/intapp/controller/file/install.txt b/app/intapp/controller/file/install.txt new file mode 100644 index 0000000..fde6665 --- /dev/null +++ b/app/intapp/controller/file/install.txt @@ -0,0 +1 @@ +kcweb \ No newline at end of file diff --git a/app/intapp/controller/file/role.txt b/app/intapp/controller/file/role.txt new file mode 100644 index 0000000..c149a50 --- /dev/null +++ b/app/intapp/controller/file/role.txt @@ -0,0 +1,15 @@ +#以下是该插件的路由,index容器会自动把以下路由加入到权限管理中 该文件必须使用utf-8编码 +文件管理页面,/intapp/file/index/index +获取分区,/intapp/file/index/disk +文件列表,/intapp/file/index/lists +上传文件,/intapp/file/index/uploadfile +删除文件,/intapp/file/index/delfile +重命名和创建文件夹,/intapp/file/index/setname +ace编辑器,/intapp/file/index/ace +保存文件内容,/intapp/file/index/savefile +获取文件内容,/intapp/file/index/getfile +压缩,/intapp/file/index/compress +解压,/intapp/file/index/decomp +下载文件,/intapp/file/index/download +显示图片,/intapp/file/index/getimg +代码编辑器,/intapp/file/index/folderace \ No newline at end of file diff --git a/app/intapp/controller/file/tpl/index/ace.html b/app/intapp/controller/file/tpl/index/ace.html new file mode 100644 index 0000000..a3f87b1 --- /dev/null +++ b/app/intapp/controller/file/tpl/index/ace.html @@ -0,0 +1,135 @@ + + + + + +文件管理 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+        
+    
+
+ + + + \ No newline at end of file diff --git a/app/intapp/controller/file/tpl/index/folderace.html b/app/intapp/controller/file/tpl/index/folderace.html new file mode 100644 index 0000000..c20f0ce --- /dev/null +++ b/app/intapp/controller/file/tpl/index/folderace.html @@ -0,0 +1,194 @@ + + + + + +文件管理 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + {{ node.label }} + + + {{ node.label }} + + + +
+
+
+                
+            
+
+
+
+
+ + + \ No newline at end of file diff --git a/app/intapp/controller/file/tpl/index/index.html b/app/intapp/controller/file/tpl/index/index.html new file mode 100644 index 0000000..240a58e --- /dev/null +++ b/app/intapp/controller/file/tpl/index/index.html @@ -0,0 +1,452 @@ + + + + + +文件管理 + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + + +
+
+ + + + +
+ +
+
+
+ + +   新建文件夹 + + + + +   上传文件 + + + + + 粘贴 + + + 复制 + 剪切 + 删除 + 下载 + + + + + 打开方式 + + + 文本编辑器 + 代码编辑器 + + + + + + + 压缩 + + + + +
zip
+
+ + +
tar
+
+
+
+ 解压 + +
+ 选择文件夹 + 选择文件 + +
+
+
+ + + + + +
+ + + + +
+ {{(item.free/1024/1024/1024).toFixed(1)}}GB可用,共{{(item.count/1024/1024/1024).toFixed(0)}}GB +
+
+ {{item.src}} +
+
+
+
+ + + + + + + + + + + + + + + + + + +
+ {{item.name}} +
+
+ +
+
+
+
+ +
+ +
上传文件
+
+
+
+
+ + + + \ No newline at end of file diff --git a/app/intapp/controller/index/admin.py b/app/intapp/controller/index/admin.py index 77c27d8..8c3b89c 100644 --- a/app/intapp/controller/index/admin.py +++ b/app/intapp/controller/index/admin.py @@ -22,6 +22,9 @@ def getpluglist(modular="intapp"): del data[i] i+=1 return successjson(data) +def dellogin(): + shutil.rmtree(config.session['path']) + return successjson() def getlist(id=0): "获取列表" if id: @@ -80,7 +83,6 @@ def update(id=0): except:pass else: sqlite("admin",model_app_path).where("id",id).update(data) - shutil.rmtree(config.session['path']) return successjson() def setpwd(): "设置管理员登录密码" @@ -149,7 +151,6 @@ def updaterole(id=0): except:pass else: sqlite("role",model_app_path).where("id",id).update(data) - shutil.rmtree(config.session['path']) return successjson() def deleterole(): "批量删除" diff --git a/app/intapp/controller/index/common/model.py b/app/intapp/controller/index/common/model.py index 26bc1f2..3e9a43f 100644 --- a/app/intapp/controller/index/common/model.py +++ b/app/intapp/controller/index/common/model.py @@ -33,28 +33,25 @@ try: except: model_intapp_interval=model_intapp_interval() model_intapp_interval.create_table() -# class model_intapp_terminal(modelsqliteintapp): -# "终端列表" -# table="terminal" -# fields={ -# "id":model.dbtype.int(LEN=11,PRI=True,A_L=True), #设置id为自增主键 -# "icon":model.dbtype.varchar(LEN=128,DEFAULT=''), -# "title":model.dbtype.varchar(LEN=128,DEFAULT=''), -# "host":model.dbtype.varchar(LEN=32,DEFAULT=''), -# "port":model.dbtype.varchar(LEN=32,DEFAULT=''), -# "username":model.dbtype.varchar(LEN=32,DEFAULT=''), -# "password":model.dbtype.varchar(LEN=32,DEFAULT=''), -# "blacklist":model.dbtype.text(), #命令黑名单 -# "whitelist":model.dbtype.text(), #命令白名单 -# "types":model.dbtype.varchar(LEN=32,DEFAULT='共享连接'), #连接方式 -# "addtime":model.dbtype.int(LEN=11,DEFAULT=0), #添加时间 -# "updtime":model.dbtype.int(LEN=11,DEFAULT=0) #添加时间 -# } -# try: -# sqlite('terminal',model_intapp_index_path).find() -# except: -# model_intapp_terminal=model_intapp_terminal() -# model_intapp_terminal.create_table() +class model_intapp_run(modelsqliteintapp): + "项目运行管理" + table="run" + fields={ + "id":model.dbtype.int(LEN=11,PRI=True,A_L=True), #设置id为自增主键 + "icon":model.dbtype.varchar(LEN=128,DEFAULT=''), + "title":model.dbtype.varchar(LEN=128,DEFAULT=''), + "descs":model.dbtype.varchar(LEN=512,DEFAULT=''), + "paths":model.dbtype.varchar(LEN=512,DEFAULT=''), #项目路径 + "filename":model.dbtype.varchar(LEN=32,DEFAULT=''), #运行文件 + "types":model.dbtype.varchar(LEN=32,DEFAULT=''), + "addtime":model.dbtype.int(LEN=11,DEFAULT=0), #添加时间 + "updtime":model.dbtype.int(LEN=11,DEFAULT=0) #添加时间 + } +try: + sqlite('run',model_intapp_index_path).find() +except: + model_intapp_run=model_intapp_run() + model_intapp_run.create_table() # class model_intapp_shelllog(modelsqliteintapp): # "终端操作日志" # table="shelllog" diff --git a/app/intapp/controller/index/setup.py b/app/intapp/controller/index/setup.py index 6d8aa15..9c345ad 100644 --- a/app/intapp/controller/index/setup.py +++ b/app/intapp/controller/index/setup.py @@ -11,7 +11,43 @@ def startpage(): def bacrecpage(): "备份恢复页面" return response.tpl() - +def run(): + "项目管理器" + return response.tpl() +def setrun(): + "设置/添加项目管理" + data=request.get_json() + if data['id']: + data.update(updtime=times(),addtime=times()) + sqlite("run").insert(data) + return successjson() + else: + del data['id'] + data.update(updtime=times(),addtime=times()) + sqlite("run").insert(data) + return successjson() +def rulists(id=''): + "项目管理列表" + if id: + return successjson(sqlite("run").find(id)) + where=None + kw=request.args.get('kw') + pagenow=request.args.get('pagenow') + pagesize=request.args.get('pagesize') + if kw: + where=[("title","like","%"+str(kw)+"%"),'or',("descs","like","%"+str(kw)+"%")] + if not pagenow: + pagenow=1 + else: + pagenow=int(pagenow) + if not pagesize: + pagesize=10 + else: + pagesize=int(pagesize) + lists=sqlite("run").where(where).page(pagenow,pagesize).select() + count=sqlite("run").where(where).count() + data=return_list(lists,count,pagenow,pagesize) + return successjson(data) def setbaseconfig(types='get'): "保存配置信息" if types=='get': diff --git a/app/intapp/controller/index/tpl/admin/index.html b/app/intapp/controller/index/tpl/admin/index.html index e87ff5d..62326c5 100644 --- a/app/intapp/controller/index/tpl/admin/index.html +++ b/app/intapp/controller/index/tpl/admin/index.html @@ -34,7 +34,10 @@ 搜索 添加管理员账户 - 角色管理 + + 角色管理 + 清除所有会话 +
@@ -145,6 +148,14 @@ var vm = new Vue({ self.getrolelist() }, methods: { + dellogin:function(){ + self.get("/intapp/index/admin/dellogin").then(function(res){ + self.$message({type: 'success',message: '所有用户已退出!'}); + setTimeout(function(){ + top.location.reload(); + },2000) + }) + }, getrolelist:function(){ self=this self.get("/intapp/index/admin/getrolelist",{'kw':self.kw,'pagesize':self.data.pagesize,'pagenow':self.data.pagenow},'获取中...').then(function(res){ diff --git a/app/intapp/controller/index/tpl/setup/index.html b/app/intapp/controller/index/tpl/setup/index.html index 4fe31a6..2ad0f95 100644 --- a/app/intapp/controller/index/tpl/setup/index.html +++ b/app/intapp/controller/index/tpl/setup/index.html @@ -38,9 +38,11 @@ 基本配置 开机启动项 备份恢复 + 项目运行管理器 计划任务 导航管理 任务队列 +
diff --git a/app/intapp/controller/index/tpl/setup/run.html b/app/intapp/controller/index/tpl/setup/run.html new file mode 100644 index 0000000..54653ec --- /dev/null +++ b/app/intapp/controller/index/tpl/setup/run.html @@ -0,0 +1,232 @@ + + + + +kcwebplus + + + + + + + + + + + + + + + + + + + +
+
+    + + + 搜索 + 添加项目 + +
+
+ + + + + + + + + + + + + +
+    删除选中  + + +
+
+ + +
+ + + + + + + + + + + +
+ +
+ +
+ +
+ + + kcweb框架 + python3.6解释器 + python2解释器 + + + + + 取 消 + 修改 + 添加 + +
+
+
+ + + -- Gitee From 8e4299c99ae79fb321c09e76016cd59e08a5f673 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 25 Aug 2020 19:13:45 +0800 Subject: [PATCH 047/202] kun --- app/intapp/controller/__init__.py | 3 +- app/intapp/controller/file/__init__.py | 1 - app/intapp/controller/file/common/__init__.py | 2 - app/intapp/controller/file/common/autoload.py | 1 - .../file/common/file/sqlite/.gitignore | 1 - app/intapp/controller/file/common/model.py | 4 - app/intapp/controller/file/index.py | 234 --------- app/intapp/controller/file/install.txt | 1 - app/intapp/controller/file/role.txt | 15 - app/intapp/controller/file/tpl/index/ace.html | 135 ------ .../controller/file/tpl/index/folderace.html | 194 -------- .../controller/file/tpl/index/index.html | 452 ------------------ 12 files changed, 1 insertion(+), 1042 deletions(-) delete mode 100644 app/intapp/controller/file/__init__.py delete mode 100644 app/intapp/controller/file/common/__init__.py delete mode 100644 app/intapp/controller/file/common/autoload.py delete mode 100644 app/intapp/controller/file/common/file/sqlite/.gitignore delete mode 100644 app/intapp/controller/file/common/model.py delete mode 100644 app/intapp/controller/file/index.py delete mode 100644 app/intapp/controller/file/install.txt delete mode 100644 app/intapp/controller/file/role.txt delete mode 100644 app/intapp/controller/file/tpl/index/ace.html delete mode 100644 app/intapp/controller/file/tpl/index/folderace.html delete mode 100644 app/intapp/controller/file/tpl/index/index.html diff --git a/app/intapp/controller/__init__.py b/app/intapp/controller/__init__.py index 16446a2..6a03892 100644 --- a/app/intapp/controller/__init__.py +++ b/app/intapp/controller/__init__.py @@ -1,3 +1,2 @@ -from . import index -from . import file \ No newline at end of file +from . import index \ No newline at end of file diff --git a/app/intapp/controller/file/__init__.py b/app/intapp/controller/file/__init__.py deleted file mode 100644 index 3471b9b..0000000 --- a/app/intapp/controller/file/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import index \ No newline at end of file diff --git a/app/intapp/controller/file/common/__init__.py b/app/intapp/controller/file/common/__init__.py deleted file mode 100644 index 60767ac..0000000 --- a/app/intapp/controller/file/common/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from .model import * \ No newline at end of file diff --git a/app/intapp/controller/file/common/autoload.py b/app/intapp/controller/file/common/autoload.py deleted file mode 100644 index eb780f3..0000000 --- a/app/intapp/controller/file/common/autoload.py +++ /dev/null @@ -1 +0,0 @@ -from app.intapp.common import * \ No newline at end of file diff --git a/app/intapp/controller/file/common/file/sqlite/.gitignore b/app/intapp/controller/file/common/file/sqlite/.gitignore deleted file mode 100644 index 72a3e83..0000000 --- a/app/intapp/controller/file/common/file/sqlite/.gitignore +++ /dev/null @@ -1 +0,0 @@ -intappindex \ No newline at end of file diff --git a/app/intapp/controller/file/common/model.py b/app/intapp/controller/file/common/model.py deleted file mode 100644 index fe6e8f6..0000000 --- a/app/intapp/controller/file/common/model.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -from .autoload import * -# 可以在这里初始化数据库 -model_intapp_file_path=os.path.split(os.path.realpath(__file__))[0]+"/file/sqlite/intappindex" #数据存放目录 diff --git a/app/intapp/controller/file/index.py b/app/intapp/controller/file/index.py deleted file mode 100644 index 75f9dc0..0000000 --- a/app/intapp/controller/file/index.py +++ /dev/null @@ -1,234 +0,0 @@ -from .common import * -import psutil -def index(): - paths=request.args.get("paths") - select=request.args.get("select") - if not paths: - paths="" - if not select: - select=0 - return response.tpl(paths=paths,systype=get_sysinfo()['platform'],select=select) -def ace(): - "编辑器页面 单文件" - filename=request.args.get('filename') - theme,mode=__get_theme_mode(filename) - return response.tpl(filename=filename,content='',theme=theme,mode=mode) -def folderace(): - "编辑器页面 文件夹" - paths=request.args.get('paths') - name=request.args.get('name') - return response.tpl(paths=paths,name=name,content='',theme='solarized_light',mode='html') -def __get_theme_mode(filename): - hz=filename.split('.')[-1] - theme='solarized_dark' ##chaos xcode - mode='io' - hz=filename.split('.')[-1] - if 'py'==hz or 'pyc'==hz: - theme="chaos" - mode='python' - elif 'php'==hz: - theme="solarized_light" - mode='php' - elif 'js'==hz: - theme="chaos" - mode='javascript' - elif 'java'==hz: - theme="chaos" - mode='java' - elif 'sh'==hz: - theme="tomorrow_night_blue" - mode='gcode' - elif 'html'==hz or 'shtml'==hz or 'htm'==hz: - mode='html' - elif 'ini'==hz or 'conf'==hz or 'config'==hz: - mode='html' - elif 'json'==hz: - mode='json' - return theme,mode -def savefile(): - "保存文件内容" - data=request.get_json() - filename=data['filename'] - content=data['content'] - encoding=data['encoding'] - file_set_content(filename,content,encoding=encoding) - return successjson() -def getfile(): - "获取文件内容" - filename=request.args.get('filename') - content,encoding=file_get_content(filename,True) - theme,mode=__get_theme_mode(filename) - return successjson({"content":content,"encoding":encoding,"theme":theme,'mode':mode}) -def disk():#磁盘分区和使用情况 - partition=[] - disk_usage=psutil.disk_usage('/') - if "Linux" in get_sysinfo()['platform']: - partition.append({ - 'name':'/','src':'分区 /',"suffix":'','types':'disk','count':disk_usage[0],'used':disk_usage[1],'free':disk_usage[2],'userate':disk_usage[3] - }) - partitions=psutil.disk_partitions() - for v in partitions: - disk_usage=psutil.disk_usage(v[0]) - if disk_usage[0]: - if "Windows" in get_sysinfo()['platform']: - partition.append({ - 'name':v[0][0:2]+"/","src":"本地磁盘 ("+v[0][0]+")","suffix":'','types':v[2],'count':disk_usage[0],'used':disk_usage[1],'free':disk_usage[2],'userate':disk_usage[3] - }) - elif "Linux" in get_sysinfo()['platform']: - partition.append({ - 'name':v[0],"src":"分区 ("+v[0]+")","suffix":'','types':v[2],'count':disk_usage[0],'used':disk_usage[1],'free':disk_usage[2],'userate':disk_usage[3] - }) - return successjson(partition) -def lists(): - "文件列表" - paths=request.args.get('paths') - kw=request.args.get('kw') - if not paths: - paths=os.path.abspath('.')+"/" - paths=paths.replace("\\", "/") - if paths[-1] != '/': - paths+="/" - if not os.path.exists(paths): - return errorjson(code=1,msg="文件夹不存在") - try: - lis=os.listdir(paths) - except: - return errorjson(code=1,msg="无法打开"+str(paths)) - lists=[] - filelist=[] - folderlist=[] - for files in lis: - if kw: - if kw in files: - if os.path.isfile(paths+files): - zd={"name":files,"src":files,"types":'file','suffix':files.split('.')[-1]} - filelist.append(zd) - elif os.path.exists(paths+files): - zd={"name":files,"src":files,"types":'folder','suffix':''} - folderlist.append(zd) - else: - zd={"name":files,"src":files,"types":'other','suffix':''} - filelist.append(zd) - else: - if os.path.isfile(paths+files): - zd={"name":files,"src":files,"types":'file','suffix':files.split('.')[-1]} - filelist.append(zd) - elif os.path.exists(paths+files): - zd={"name":files,"src":files,"types":'folder','suffix':''} - folderlist.append(zd) - else: - zd={"name":files,"src":files,"types":'other','suffix':''} - filelist.append(zd) - lists=folderlist+filelist - if lists: - data=return_list(lists,count=len(lis),pagenow=1,pagesize=1) - else: - data=return_list(lists,count=0,pagenow=1,pagesize=1) - data['paths']=paths - pathss=paths.split('/') - for i in pathss: - if i=='': - pathss.remove(i) - data['pathss']=pathss - "文件列表" - return successjson(data) -def uploadfile(): - paths=request.args.get('paths') - "上传文件" - if request.binary.save('file',paths+request.binary.filename('file')): - return successjson() - else: - return errorjson(msg="上传失败") -def delfile(): - "删除文件" - data=request.get_json() - paths=data['paths'] - lists=data['lists'] - for k in lists: - if k['types']=='file': #删除文件 - if os.path.isfile(paths+k['name']): - os.remove(paths+k['name']) - else: #删除文件夹 - shutil.rmtree(paths+k['name']) - return successjson(data) -def setname(): - "重命名和创建文件夹" - data=request.get_json() - paths=data['paths'] - src=data['src'] - dst=data['dst'] - if os.path.exists(paths+src): - if src != dst: #重命名文件夹 - os.rename(paths+src,paths+dst) - else: #创建文件夹 - if not os.path.exists(paths+dst): - os.makedirs(paths+dst) - else: - return errorjson(msg="该文件夹已存在") - return successjson() -def compress(types='zip'): - "压缩" - pathfile=request.args.get("pathfile") - if pathfile[-1]=='/': - filename=pathfile[:-1]+"."+types - else: - filename=pathfile+"."+types - if types=='zip': - zip.packzip(pathfile,filename) - elif types=='tar': - kcwtar.targz(pathfile,filename) - return successjson() -def decomp(types='zip'): - "解压" - filename=request.args.get("filename") - pathfilearr=filename.split(".") - pathfile='' - i=0 - while True: - if i>= (len(pathfilearr)-1): - break - else: - pathfile+=pathfilearr[i] - i+=1 - if types=='zip': - zip.unzip_file(filename,pathfile) - elif types=='tar': - kcwtar.untar(filename,pathfile) - else: - try: - zip.unzip_file(filename,pathfile) - except: - try: - kcwtar.untar(filename,pathfile) - except: - return errorjson("无法解压该压缩包") - return successjson() -def download(name): - "下载文件" - pathname=request.args.get("pathname") - return response.download(pathname) -def paste(): - "复制/移动文件" - copy=request.get_json() - pathname=copy['paths'] - dsc=copy['dsc'] - if os.path.isfile(pathname) or os.path.exists(pathname): - dsc+=pathname.split("/")[-1] - if os.path.exists(dsc): - dsc+=" copy" - if copy['types']=='copy': #复制 - if os.path.isfile(pathname): - shutil.copyfile(pathname,dsc) - else: - shutil.copytree(pathname,dsc) - elif copy['types']=='shear': #移动 - shutil.move(pathname,dsc) - else: - return errorjson("类型错误") - else: - return errorjson("您选择的文件不存在") - return successjson() -def getimg(): - "显示图片" - filename=request.args.get('filename') - return response.pic(filename) \ No newline at end of file diff --git a/app/intapp/controller/file/install.txt b/app/intapp/controller/file/install.txt deleted file mode 100644 index fde6665..0000000 --- a/app/intapp/controller/file/install.txt +++ /dev/null @@ -1 +0,0 @@ -kcweb \ No newline at end of file diff --git a/app/intapp/controller/file/role.txt b/app/intapp/controller/file/role.txt deleted file mode 100644 index c149a50..0000000 --- a/app/intapp/controller/file/role.txt +++ /dev/null @@ -1,15 +0,0 @@ -#以下是该插件的路由,index容器会自动把以下路由加入到权限管理中 该文件必须使用utf-8编码 -文件管理页面,/intapp/file/index/index -获取分区,/intapp/file/index/disk -文件列表,/intapp/file/index/lists -上传文件,/intapp/file/index/uploadfile -删除文件,/intapp/file/index/delfile -重命名和创建文件夹,/intapp/file/index/setname -ace编辑器,/intapp/file/index/ace -保存文件内容,/intapp/file/index/savefile -获取文件内容,/intapp/file/index/getfile -压缩,/intapp/file/index/compress -解压,/intapp/file/index/decomp -下载文件,/intapp/file/index/download -显示图片,/intapp/file/index/getimg -代码编辑器,/intapp/file/index/folderace \ No newline at end of file diff --git a/app/intapp/controller/file/tpl/index/ace.html b/app/intapp/controller/file/tpl/index/ace.html deleted file mode 100644 index a3f87b1..0000000 --- a/app/intapp/controller/file/tpl/index/ace.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - - -文件管理 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-        
-    
-
- - - - \ No newline at end of file diff --git a/app/intapp/controller/file/tpl/index/folderace.html b/app/intapp/controller/file/tpl/index/folderace.html deleted file mode 100644 index c20f0ce..0000000 --- a/app/intapp/controller/file/tpl/index/folderace.html +++ /dev/null @@ -1,194 +0,0 @@ - - - - - -文件管理 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - {{ node.label }} - - - {{ node.label }} - - - -
-
-
-                
-            
-
-
-
-
- - - \ No newline at end of file diff --git a/app/intapp/controller/file/tpl/index/index.html b/app/intapp/controller/file/tpl/index/index.html deleted file mode 100644 index 240a58e..0000000 --- a/app/intapp/controller/file/tpl/index/index.html +++ /dev/null @@ -1,452 +0,0 @@ - - - - - -文件管理 - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - - - - - -
-
- - - - -
- -
-
-
- - -   新建文件夹 - - - - -   上传文件 - - - - - 粘贴 - - - 复制 - 剪切 - 删除 - 下载 - - - - - 打开方式 - - - 文本编辑器 - 代码编辑器 - - - - - - - 压缩 - - - - -
zip
-
- - -
tar
-
-
-
- 解压 - -
- 选择文件夹 - 选择文件 - -
-
-
- - - - - -
- - - - -
- {{(item.free/1024/1024/1024).toFixed(1)}}GB可用,共{{(item.count/1024/1024/1024).toFixed(0)}}GB -
-
- {{item.src}} -
-
-
-
- - - - - - - - - - - - - - - - - - -
- {{item.name}} -
-
- -
-
-
-
- -
- -
上传文件
-
-
-
-
- - - - \ No newline at end of file -- Gitee From 6da5b2fb456695a42eecc6609ae6ab55425d1648 Mon Sep 17 00:00:00 2001 From: kunkun Date: Tue, 25 Aug 2020 21:32:06 +0800 Subject: [PATCH 048/202] kun --- app/intapp/controller/__init__.py | 3 +- app/intapp/controller/file/__init__.py | 1 + app/intapp/controller/file/common/__init__.py | 2 + app/intapp/controller/file/common/autoload.py | 1 + .../file/common/file/sqlite/.gitignore | 1 + app/intapp/controller/file/common/model.py | 4 + app/intapp/controller/file/index.py | 234 +++++++++ app/intapp/controller/file/install.txt | 1 + app/intapp/controller/file/role.txt | 15 + app/intapp/controller/file/tpl/index/ace.html | 135 ++++++ .../controller/file/tpl/index/folderace.html | 194 ++++++++ .../controller/file/tpl/index/index.html | 452 ++++++++++++++++++ .../controller/index/common/autoload.py | 9 +- app/intapp/controller/index/common/model.py | 13 +- app/intapp/controller/index/setup.py | 68 ++- .../index/tpl/setup/index copy.html | 334 ------------- .../controller/index/tpl/setup/index.html | 2 +- .../tpl/setup/{run.html => pythonrun.html} | 77 ++- 18 files changed, 1145 insertions(+), 401 deletions(-) create mode 100644 app/intapp/controller/file/__init__.py create mode 100644 app/intapp/controller/file/common/__init__.py create mode 100644 app/intapp/controller/file/common/autoload.py create mode 100644 app/intapp/controller/file/common/file/sqlite/.gitignore create mode 100644 app/intapp/controller/file/common/model.py create mode 100644 app/intapp/controller/file/index.py create mode 100644 app/intapp/controller/file/install.txt create mode 100644 app/intapp/controller/file/role.txt create mode 100644 app/intapp/controller/file/tpl/index/ace.html create mode 100644 app/intapp/controller/file/tpl/index/folderace.html create mode 100644 app/intapp/controller/file/tpl/index/index.html delete mode 100644 app/intapp/controller/index/tpl/setup/index copy.html rename app/intapp/controller/index/tpl/setup/{run.html => pythonrun.html} (77%) diff --git a/app/intapp/controller/__init__.py b/app/intapp/controller/__init__.py index 6a03892..16446a2 100644 --- a/app/intapp/controller/__init__.py +++ b/app/intapp/controller/__init__.py @@ -1,2 +1,3 @@ -from . import index \ No newline at end of file +from . import index +from . import file \ No newline at end of file diff --git a/app/intapp/controller/file/__init__.py b/app/intapp/controller/file/__init__.py new file mode 100644 index 0000000..3471b9b --- /dev/null +++ b/app/intapp/controller/file/__init__.py @@ -0,0 +1 @@ +from . import index \ No newline at end of file diff --git a/app/intapp/controller/file/common/__init__.py b/app/intapp/controller/file/common/__init__.py new file mode 100644 index 0000000..60767ac --- /dev/null +++ b/app/intapp/controller/file/common/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from .model import * \ No newline at end of file diff --git a/app/intapp/controller/file/common/autoload.py b/app/intapp/controller/file/common/autoload.py new file mode 100644 index 0000000..eb780f3 --- /dev/null +++ b/app/intapp/controller/file/common/autoload.py @@ -0,0 +1 @@ +from app.intapp.common import * \ No newline at end of file diff --git a/app/intapp/controller/file/common/file/sqlite/.gitignore b/app/intapp/controller/file/common/file/sqlite/.gitignore new file mode 100644 index 0000000..72a3e83 --- /dev/null +++ b/app/intapp/controller/file/common/file/sqlite/.gitignore @@ -0,0 +1 @@ +intappindex \ No newline at end of file diff --git a/app/intapp/controller/file/common/model.py b/app/intapp/controller/file/common/model.py new file mode 100644 index 0000000..fe6e8f6 --- /dev/null +++ b/app/intapp/controller/file/common/model.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from .autoload import * +# 可以在这里初始化数据库 +model_intapp_file_path=os.path.split(os.path.realpath(__file__))[0]+"/file/sqlite/intappindex" #数据存放目录 diff --git a/app/intapp/controller/file/index.py b/app/intapp/controller/file/index.py new file mode 100644 index 0000000..75f9dc0 --- /dev/null +++ b/app/intapp/controller/file/index.py @@ -0,0 +1,234 @@ +from .common import * +import psutil +def index(): + paths=request.args.get("paths") + select=request.args.get("select") + if not paths: + paths="" + if not select: + select=0 + return response.tpl(paths=paths,systype=get_sysinfo()['platform'],select=select) +def ace(): + "编辑器页面 单文件" + filename=request.args.get('filename') + theme,mode=__get_theme_mode(filename) + return response.tpl(filename=filename,content='',theme=theme,mode=mode) +def folderace(): + "编辑器页面 文件夹" + paths=request.args.get('paths') + name=request.args.get('name') + return response.tpl(paths=paths,name=name,content='',theme='solarized_light',mode='html') +def __get_theme_mode(filename): + hz=filename.split('.')[-1] + theme='solarized_dark' ##chaos xcode + mode='io' + hz=filename.split('.')[-1] + if 'py'==hz or 'pyc'==hz: + theme="chaos" + mode='python' + elif 'php'==hz: + theme="solarized_light" + mode='php' + elif 'js'==hz: + theme="chaos" + mode='javascript' + elif 'java'==hz: + theme="chaos" + mode='java' + elif 'sh'==hz: + theme="tomorrow_night_blue" + mode='gcode' + elif 'html'==hz or 'shtml'==hz or 'htm'==hz: + mode='html' + elif 'ini'==hz or 'conf'==hz or 'config'==hz: + mode='html' + elif 'json'==hz: + mode='json' + return theme,mode +def savefile(): + "保存文件内容" + data=request.get_json() + filename=data['filename'] + content=data['content'] + encoding=data['encoding'] + file_set_content(filename,content,encoding=encoding) + return successjson() +def getfile(): + "获取文件内容" + filename=request.args.get('filename') + content,encoding=file_get_content(filename,True) + theme,mode=__get_theme_mode(filename) + return successjson({"content":content,"encoding":encoding,"theme":theme,'mode':mode}) +def disk():#磁盘分区和使用情况 + partition=[] + disk_usage=psutil.disk_usage('/') + if "Linux" in get_sysinfo()['platform']: + partition.append({ + 'name':'/','src':'分区 /',"suffix":'','types':'disk','count':disk_usage[0],'used':disk_usage[1],'free':disk_usage[2],'userate':disk_usage[3] + }) + partitions=psutil.disk_partitions() + for v in partitions: + disk_usage=psutil.disk_usage(v[0]) + if disk_usage[0]: + if "Windows" in get_sysinfo()['platform']: + partition.append({ + 'name':v[0][0:2]+"/","src":"本地磁盘 ("+v[0][0]+")","suffix":'','types':v[2],'count':disk_usage[0],'used':disk_usage[1],'free':disk_usage[2],'userate':disk_usage[3] + }) + elif "Linux" in get_sysinfo()['platform']: + partition.append({ + 'name':v[0],"src":"分区 ("+v[0]+")","suffix":'','types':v[2],'count':disk_usage[0],'used':disk_usage[1],'free':disk_usage[2],'userate':disk_usage[3] + }) + return successjson(partition) +def lists(): + "文件列表" + paths=request.args.get('paths') + kw=request.args.get('kw') + if not paths: + paths=os.path.abspath('.')+"/" + paths=paths.replace("\\", "/") + if paths[-1] != '/': + paths+="/" + if not os.path.exists(paths): + return errorjson(code=1,msg="文件夹不存在") + try: + lis=os.listdir(paths) + except: + return errorjson(code=1,msg="无法打开"+str(paths)) + lists=[] + filelist=[] + folderlist=[] + for files in lis: + if kw: + if kw in files: + if os.path.isfile(paths+files): + zd={"name":files,"src":files,"types":'file','suffix':files.split('.')[-1]} + filelist.append(zd) + elif os.path.exists(paths+files): + zd={"name":files,"src":files,"types":'folder','suffix':''} + folderlist.append(zd) + else: + zd={"name":files,"src":files,"types":'other','suffix':''} + filelist.append(zd) + else: + if os.path.isfile(paths+files): + zd={"name":files,"src":files,"types":'file','suffix':files.split('.')[-1]} + filelist.append(zd) + elif os.path.exists(paths+files): + zd={"name":files,"src":files,"types":'folder','suffix':''} + folderlist.append(zd) + else: + zd={"name":files,"src":files,"types":'other','suffix':''} + filelist.append(zd) + lists=folderlist+filelist + if lists: + data=return_list(lists,count=len(lis),pagenow=1,pagesize=1) + else: + data=return_list(lists,count=0,pagenow=1,pagesize=1) + data['paths']=paths + pathss=paths.split('/') + for i in pathss: + if i=='': + pathss.remove(i) + data['pathss']=pathss + "文件列表" + return successjson(data) +def uploadfile(): + paths=request.args.get('paths') + "上传文件" + if request.binary.save('file',paths+request.binary.filename('file')): + return successjson() + else: + return errorjson(msg="上传失败") +def delfile(): + "删除文件" + data=request.get_json() + paths=data['paths'] + lists=data['lists'] + for k in lists: + if k['types']=='file': #删除文件 + if os.path.isfile(paths+k['name']): + os.remove(paths+k['name']) + else: #删除文件夹 + shutil.rmtree(paths+k['name']) + return successjson(data) +def setname(): + "重命名和创建文件夹" + data=request.get_json() + paths=data['paths'] + src=data['src'] + dst=data['dst'] + if os.path.exists(paths+src): + if src != dst: #重命名文件夹 + os.rename(paths+src,paths+dst) + else: #创建文件夹 + if not os.path.exists(paths+dst): + os.makedirs(paths+dst) + else: + return errorjson(msg="该文件夹已存在") + return successjson() +def compress(types='zip'): + "压缩" + pathfile=request.args.get("pathfile") + if pathfile[-1]=='/': + filename=pathfile[:-1]+"."+types + else: + filename=pathfile+"."+types + if types=='zip': + zip.packzip(pathfile,filename) + elif types=='tar': + kcwtar.targz(pathfile,filename) + return successjson() +def decomp(types='zip'): + "解压" + filename=request.args.get("filename") + pathfilearr=filename.split(".") + pathfile='' + i=0 + while True: + if i>= (len(pathfilearr)-1): + break + else: + pathfile+=pathfilearr[i] + i+=1 + if types=='zip': + zip.unzip_file(filename,pathfile) + elif types=='tar': + kcwtar.untar(filename,pathfile) + else: + try: + zip.unzip_file(filename,pathfile) + except: + try: + kcwtar.untar(filename,pathfile) + except: + return errorjson("无法解压该压缩包") + return successjson() +def download(name): + "下载文件" + pathname=request.args.get("pathname") + return response.download(pathname) +def paste(): + "复制/移动文件" + copy=request.get_json() + pathname=copy['paths'] + dsc=copy['dsc'] + if os.path.isfile(pathname) or os.path.exists(pathname): + dsc+=pathname.split("/")[-1] + if os.path.exists(dsc): + dsc+=" copy" + if copy['types']=='copy': #复制 + if os.path.isfile(pathname): + shutil.copyfile(pathname,dsc) + else: + shutil.copytree(pathname,dsc) + elif copy['types']=='shear': #移动 + shutil.move(pathname,dsc) + else: + return errorjson("类型错误") + else: + return errorjson("您选择的文件不存在") + return successjson() +def getimg(): + "显示图片" + filename=request.args.get('filename') + return response.pic(filename) \ No newline at end of file diff --git a/app/intapp/controller/file/install.txt b/app/intapp/controller/file/install.txt new file mode 100644 index 0000000..fde6665 --- /dev/null +++ b/app/intapp/controller/file/install.txt @@ -0,0 +1 @@ +kcweb \ No newline at end of file diff --git a/app/intapp/controller/file/role.txt b/app/intapp/controller/file/role.txt new file mode 100644 index 0000000..c149a50 --- /dev/null +++ b/app/intapp/controller/file/role.txt @@ -0,0 +1,15 @@ +#以下是该插件的路由,index容器会自动把以下路由加入到权限管理中 该文件必须使用utf-8编码 +文件管理页面,/intapp/file/index/index +获取分区,/intapp/file/index/disk +文件列表,/intapp/file/index/lists +上传文件,/intapp/file/index/uploadfile +删除文件,/intapp/file/index/delfile +重命名和创建文件夹,/intapp/file/index/setname +ace编辑器,/intapp/file/index/ace +保存文件内容,/intapp/file/index/savefile +获取文件内容,/intapp/file/index/getfile +压缩,/intapp/file/index/compress +解压,/intapp/file/index/decomp +下载文件,/intapp/file/index/download +显示图片,/intapp/file/index/getimg +代码编辑器,/intapp/file/index/folderace \ No newline at end of file diff --git a/app/intapp/controller/file/tpl/index/ace.html b/app/intapp/controller/file/tpl/index/ace.html new file mode 100644 index 0000000..a3f87b1 --- /dev/null +++ b/app/intapp/controller/file/tpl/index/ace.html @@ -0,0 +1,135 @@ + + + + + +文件管理 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+        
+    
+
+ + + + \ No newline at end of file diff --git a/app/intapp/controller/file/tpl/index/folderace.html b/app/intapp/controller/file/tpl/index/folderace.html new file mode 100644 index 0000000..c20f0ce --- /dev/null +++ b/app/intapp/controller/file/tpl/index/folderace.html @@ -0,0 +1,194 @@ + + + + + +文件管理 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + {{ node.label }} + + + {{ node.label }} + + + +
+
+
+                
+            
+
+
+
+
+ + + \ No newline at end of file diff --git a/app/intapp/controller/file/tpl/index/index.html b/app/intapp/controller/file/tpl/index/index.html new file mode 100644 index 0000000..240a58e --- /dev/null +++ b/app/intapp/controller/file/tpl/index/index.html @@ -0,0 +1,452 @@ + + + + + +文件管理 + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + + +
+
+ + + + +
+ +
+
+
+ + +   新建文件夹 + + + + +   上传文件 + + + + + 粘贴 + + + 复制 + 剪切 + 删除 + 下载 + + + + + 打开方式 + + + 文本编辑器 + 代码编辑器 + + + + + + + 压缩 + + + + +
zip
+
+ + +
tar
+
+
+
+ 解压 + +
+ 选择文件夹 + 选择文件 + +
+
+
+ + + + + +
+ + + + +
+ {{(item.free/1024/1024/1024).toFixed(1)}}GB可用,共{{(item.count/1024/1024/1024).toFixed(0)}}GB +
+
+ {{item.src}} +
+
+
+
+ + + + + + + + + + + + + + + + + + +
+ {{item.name}} +
+
+ +
+
+
+
+ +
+ +
上传文件
+
+
+
+
+ + + + \ No newline at end of file diff --git a/app/intapp/controller/index/common/autoload.py b/app/intapp/controller/index/common/autoload.py index e9ece29..a98a5a1 100644 --- a/app/intapp/controller/index/common/autoload.py +++ b/app/intapp/controller/index/common/autoload.py @@ -1,3 +1,10 @@ from app.intapp.common import * from apscheduler.schedulers.blocking import BlockingScheduler -import threading,subprocess,multiprocessing \ No newline at end of file +import threading,subprocess,multiprocessing +def get_process_id(name): + try: + child = subprocess.Popen(['pgrep', '-f', name],stdout=subprocess.PIPE, shell=False) + response = child.communicate()[0] + return [int(pid) for pid in response.split()] + except: + return [] \ No newline at end of file diff --git a/app/intapp/controller/index/common/model.py b/app/intapp/controller/index/common/model.py index 3e9a43f..dc6467e 100644 --- a/app/intapp/controller/index/common/model.py +++ b/app/intapp/controller/index/common/model.py @@ -33,9 +33,9 @@ try: except: model_intapp_interval=model_intapp_interval() model_intapp_interval.create_table() -class model_intapp_run(modelsqliteintapp): +class model_intapp_pythonrun(modelsqliteintapp): "项目运行管理" - table="run" + table="pythonrun" fields={ "id":model.dbtype.int(LEN=11,PRI=True,A_L=True), #设置id为自增主键 "icon":model.dbtype.varchar(LEN=128,DEFAULT=''), @@ -43,15 +43,16 @@ class model_intapp_run(modelsqliteintapp): "descs":model.dbtype.varchar(LEN=512,DEFAULT=''), "paths":model.dbtype.varchar(LEN=512,DEFAULT=''), #项目路径 "filename":model.dbtype.varchar(LEN=32,DEFAULT=''), #运行文件 - "types":model.dbtype.varchar(LEN=32,DEFAULT=''), + "types":model.dbtype.varchar(LEN=32,DEFAULT=''), + "other":model.dbtype.varchar(LEN=512,DEFAULT=''), "addtime":model.dbtype.int(LEN=11,DEFAULT=0), #添加时间 "updtime":model.dbtype.int(LEN=11,DEFAULT=0) #添加时间 } try: - sqlite('run',model_intapp_index_path).find() + sqlite('pythonrun',model_intapp_index_path).find() except: - model_intapp_run=model_intapp_run() - model_intapp_run.create_table() + model_intapp_pythonrun=model_intapp_pythonrun() + model_intapp_pythonrun.create_table() # class model_intapp_shelllog(modelsqliteintapp): # "终端操作日志" # table="shelllog" diff --git a/app/intapp/controller/index/setup.py b/app/intapp/controller/index/setup.py index 9c345ad..b243a0c 100644 --- a/app/intapp/controller/index/setup.py +++ b/app/intapp/controller/index/setup.py @@ -11,25 +11,59 @@ def startpage(): def bacrecpage(): "备份恢复页面" return response.tpl() -def run(): +def pythonrun(): "项目管理器" return response.tpl() -def setrun(): +def setpythonrun(): "设置/添加项目管理" - data=request.get_json() - if data['id']: - data.update(updtime=times(),addtime=times()) - sqlite("run").insert(data) - return successjson() + if 'Linux' in get_sysinfo()['platform']: + data=request.get_json() + + interpreter=md5(data['paths']+data['types']+data['filename']) #解释器 + if not os.path.isfile("/usr/bin/python3.6website"): + os.system("ln -s /usr/local/python/python3.6/bin/python3 /usr/bin/python/"+interpreter) + if data['other']: #带运行参数 + os.system("cd "+data['paths']+"&& "+interpreter+" "+data['filename']+" "+data['other']) + else: + os.system("cd "+data['paths']+"&& "+interpreter+" "+data['filename']) + time.sleep(1) + if get_process_id(interpreter): + if data['id']: + arr=sqlite("pythonrun").where("id",data['id']).find() + interpreterj=md5(arr['paths']+arr['types']+arr['filename']) #解释器 + if interpreterj!=interpreter:#删除之前的 + os.system("pkill -9 "+interpreterj) + os.remove("/usr/bin/python/"+interpreterj) + data.update(updtime=times(),addtime=times()) + sqlite("pythonrun").where("id",data['id']).update(data) + return successjson() + else: + del data['id'] + data.update(updtime=times(),addtime=times()) + sqlite("pythonrun").insert(data) + return successjson() + else: + return errorjson() + else: + return errorjson(msg="不支持该系统,当前只支持linux") +def delpythonrun(): + "删除项目管理" + try: + id=request.get_json() + arr=sqlite("pythonrun").where('id','in',id).field("paths,types,filename").select() + for k in arr: + interpreter=md5(k['paths']+['types']+k['filename']) #解释器 + os.system("pkill -9 "+interpreter) + os.remove("/usr/bin/python/"+interpreter) + sqlite("pythonrun").where('id','in',id).delete() + except: + return errorjson(msg="失败") else: - del data['id'] - data.update(updtime=times(),addtime=times()) - sqlite("run").insert(data) return successjson() -def rulists(id=''): +def pythonrulists(id=''): "项目管理列表" if id: - return successjson(sqlite("run").find(id)) + return successjson(sqlite("pythonrun").find(id)) where=None kw=request.args.get('kw') pagenow=request.args.get('pagenow') @@ -44,8 +78,14 @@ def rulists(id=''): pagesize=10 else: pagesize=int(pagesize) - lists=sqlite("run").where(where).page(pagenow,pagesize).select() - count=sqlite("run").where(where).count() + lists=sqlite("pythonrun").where(where).page(pagenow,pagesize).select() + for k in lists: + interpreter=md5(k['paths']+k['types']+k['filename']) #解释器 + if get_process_id(interpreter): + k['status']=1 #运行中 + else: + k['status']=0 #已停止 + count=sqlite("pythonrun").where(where).count() data=return_list(lists,count,pagenow,pagesize) return successjson(data) def setbaseconfig(types='get'): diff --git a/app/intapp/controller/index/tpl/setup/index copy.html b/app/intapp/controller/index/tpl/setup/index copy.html deleted file mode 100644 index 2355ec3..0000000 --- a/app/intapp/controller/index/tpl/setup/index copy.html +++ /dev/null @@ -1,334 +0,0 @@ - - - - - -kcwebplus - - - - - - - - - - - - - - - - - - - -
-
- - -
-    - - 添加启动项 - -
- - - - - - - - - - - - - -
- -
-
- 备份所有 - 恢复所有 - 下载备份文件 -
-
- - -
将备份文件拖到此处,或点击上传
-
只能上传压缩包zip文件
-
-
-
-
-

阿里云oss文稿备份点

- - - - - - - - -
-
-

阿里云oss mysql备份点

- - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - 保存 - - - - -
- - - - - - - - - - - 取 消 - 添加 - - -
-
- - - \ No newline at end of file diff --git a/app/intapp/controller/index/tpl/setup/index.html b/app/intapp/controller/index/tpl/setup/index.html index 2ad0f95..4ed53c0 100644 --- a/app/intapp/controller/index/tpl/setup/index.html +++ b/app/intapp/controller/index/tpl/setup/index.html @@ -38,7 +38,7 @@ 基本配置 开机启动项 备份恢复 - 项目运行管理器 + python项目管理器 计划任务 导航管理 任务队列 diff --git a/app/intapp/controller/index/tpl/setup/run.html b/app/intapp/controller/index/tpl/setup/pythonrun.html similarity index 77% rename from app/intapp/controller/index/tpl/setup/run.html rename to app/intapp/controller/index/tpl/setup/pythonrun.html index 54653ec..7608311 100644 --- a/app/intapp/controller/index/tpl/setup/run.html +++ b/app/intapp/controller/index/tpl/setup/pythonrun.html @@ -32,11 +32,11 @@ 搜索 - 添加项目 + 添加项目
- +