diff --git a/README.md b/README.md
index 2b9934e28b66809c4883d79adfc09e5bdb01a4a6..f5367bf867938f078111223fbb0790f760175c8e 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,5 @@
-centos安装命令:wget http://file.kwebapp.cn/sh/install/intapp/kcwebplus.sh && bash kcwebplus.sh
\ No newline at end of file
+centos安装命令:wget http://file.kwebapp.cn/sh/install/intapp/kcwebplus.sh && bash kcwebplus.sh
+
+tar zcvf lkmall.chengliao.com.tar.gz lkmall.chengliao.com
+scp -r /www/lkmall.chengliao.com.tar.gz 47.97.115.105:/www/
\ No newline at end of file
diff --git a/app/__init__.py b/app/__init__.py
index ed8d0eb2f85edf9e65d66ceb592f16753d300409..ce98ea678e0e68c9e900fa7d4a6c7b32f2238fb0 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 index
\ No newline at end of file
diff --git a/app/common/__init__.py b/app/common/__init__.py
index 2629661e0659a720418988bac392ec98226899d2..5609cbcea36920e562477f5cbb74b3b4cb2625e8 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()
@@ -144,7 +144,7 @@ def return_list(lists,count,pagenow,pagesize):
'lists':lists
}
return data
-def successjson(data=[],code=0,msg="成功",status='200 ok'):
+def successjson(data=[],code=0,msg="成功",status='200 ok',cache=False):
"""成功说在浏览器输出包装过的json
参数 data 结果 默认[]
@@ -155,6 +155,8 @@ def successjson(data=[],code=0,msg="成功",status='200 ok'):
参数 status http状态码 默认 200
+ 参数 cache 是否启用浏览器缓存(状态码304缓存)
+
返回 json字符串结果集
"""
res={
@@ -163,8 +165,8 @@ def successjson(data=[],code=0,msg="成功",status='200 ok'):
"time":int(time.time()),
"data":data
}
- return response.json(res,status)
-def errorjson(data=[],code=1,msg="失败",status='400 error'):
+ return response.json(res,status,response_cache=cache)
+def errorjson(data=[],code=1,msg="失败",status='400 error',cache=False):
"""错误时在浏览器输出包装过的json
参数 data 结果 默认[]
@@ -175,9 +177,11 @@ def errorjson(data=[],code=1,msg="失败",status='400 error'):
参数 status http状态码 默认 200
+ 参数 cache 是否启用浏览器缓存(状态码304缓存)
+
返回 json字符串结果集
"""
- return successjson(data=data,code=code,msg=msg,status=status)
+ return successjson(data=data,code=code,msg=msg,status=status,cache=cache)
def randoms(lens=6,types=1):
"""生成随机字符串
@@ -215,11 +219,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:
@@ -254,7 +259,7 @@ class system_start:
vague 是否模糊匹配
"""
if id:
- where=[("id","eq",id),"and",("admin_id","gt",0)]
+ where=[("id","eq",id)]
if 'Linux' in get_sysinfo()['uname'][0]:
if vague:
f = open("/usr/bin/startkcweb")
@@ -293,4 +298,12 @@ def get_local_ip():
g_local_ip = [l for l in (ip_from_ip_port, ip_from_host_name) if l][0]
except (Exception) as e:
print("get_local_ip found exception : %s" % e)
- return g_local_ip if("" != g_local_ip and None != g_local_ip) else socket.gethostbyname(socket.gethostname())
\ No newline at end of file
+ return g_local_ip if("" != g_local_ip and None != g_local_ip) else socket.gethostbyname(socket.gethostname())
+
+def sysisphone():
+ "判断是不是手机端访问"
+ HTTP_USER_AGENT=request.HEADER.GET()['HTTP_USER_AGENT']
+ if "Android" in HTTP_USER_AGENT or 'iPhone' in HTTP_USER_AGENT:
+ return True
+ else:
+ return False
\ No newline at end of file
diff --git a/app/common/file/config.conf b/app/common/file/config.conf
index a6aee50895cca581173ea2e52690b592a6273b76..e5c0567887dfa7315c8eda88577f500ddc8fa05b 100644
--- a/app/common/file/config.conf
+++ b/app/common/file/config.conf
@@ -1 +1 @@
-{"aliyun": {"address": "http://oss-cn-beijing.aliyuncs.com", "bucket": "fanshubackups", "access_key": "LTAISSz1gBwL1oOo", "access_key_secret": "MoGi9FusUZx6Vjp8FgLrRkxU22kFON", "backpath": "kcweb"}}
\ No newline at end of file
+{"aliyun": {"address": "http://oss-cn-beijing.aliyuncs.com", "bucket": "", "access_key": "", "access_key_secret": "", "backpath": "kcweb"}, "system": {"name": "kcwebplus-云管", "logo": "https://imgmt.kwebapp.cn/icon/api.png", "kcwebuser": {}}}
\ No newline at end of file
diff --git a/app/common/html/login.html b/app/common/html/login.html
index 09094684a4199a77c5826e6899730801536b3028..9f7c7517503f41a20ab7b1259486091bff0b9364 100644
--- a/app/common/html/login.html
+++ b/app/common/html/login.html
@@ -66,7 +66,7 @@ var vm = new Vue({
timestamp= Date.parse(new Date())/1000;
random=md5('feafwefasas'+timestamp)
sign=md5(self.username+md5('kcw'+self.password)+timestamp+random)
- self.get("/intapp/index/pub/login/"+self.username+"/"+sign+"/"+timestamp+"/"+random,{},'登录中...').then(function(res){
+ self.get("/index/index/index/login/"+self.username+"/"+sign+"/"+timestamp+"/"+random,{},'登录中...').then(function(res){
if(res.code==0){
location.reload()
}
diff --git a/app/common/model.py b/app/common/model.py
index 7c60028f43c889376ec2e8e25647bcdb79235b1b..44947a409cec030dda9e8713d062dd8f43035ffb 100644
--- a/app/common/model.py
+++ b/app/common/model.py
@@ -74,7 +74,7 @@ class model_intapp_menu(modelsqliteintapp):
sqlite('menu',model_app_path).where("title='"+title+"' and sort='"+str(sort)+"'").delete()
elif title and types:
sqlite('menu',model_app_path).where("title='"+title+"' and types='"+types+"'").delete()
- elif title and admin_id:
+ else:
sqlite('menu',model_app_path).where("title='"+title+"' and admin_id='"+str(admin_id)+"'").delete()
diff --git a/app/config/app.py b/app/config/app.py
index 12b586740c1724f502211511ef1ddcf374db0ff9..af79eb967ba660e852f8ebafa312808afadbda19 100644
--- a/app/config/app.py
+++ b/app/config/app.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from .database import *
-app['app_debug']=True #是否开启调试模式
+app['app_debug']=False #是否开启调试模式
app['tpl_folder']='./app' #设置模板文件目录名 注意:所有的配置目录都是以您的运行文件所在目录开始
app['before_request']='before_request' #设置请求前要执行的函数名
app['after_request']='after_request' #设置请求后要执行的函数名
@@ -33,24 +33,15 @@ email['sendNick']='' #发件人昵称
email['theme']='' #默认主题
email['recNick']='' #默认收件人昵称
-#mongodb配置
-mongo['host']='127.0.0.1'
-mongo['port']='27017'
-mongo['user']=''
-mongo['password']=''
-mongo['db']='test'
-mongo['retryWrites']=False #是否支持重新写入
-
#路由配置
route['default']=True #是否开启默认路由 默认路由开启后面不影响以下配置的路由,模块名/版本名/控制器文件名/方法名 作为路由地址 如:http://www.kcw.com/modular/plug/index/index/
-route['modular']='' #指定访问配置固定模块 (如果配置了该值,将无法通过改变url访问不同模块)
-route['plug']='' #指定访问固定插件 (如果配置了该值,将无法通过改变url访问不同插件)
+route['modular']="" #指定访问配置固定模块 (如果匹配了该值,将无法通过改变url访问不同模块)
+route['plug']="" #指定访问固定插件 (如果匹配了该值,将无法通过改变url访问不同插件)
route['defmodular']='intapp' #默认模块 当url不包括模块名时
route['defplug']='index' #默认插件 当url不包括插件名时
route['files']='index' #默认路由文件(控制器) 当url不包括控制器名时
route['funct']='index' #默认路由函数 (操作方法) 当url不包括操作方法名时
route['methods']=['POST','GET'] #默认请求方式
-#sqlite配置
-sqlite['db']='kcwlicuxweb' #sqlite数据库文件
+
diff --git a/app/config/database.py b/app/config/database.py
index 6fb9289f63637d9a46cd57ff1917e2685540d1a2..c27b858d15e04ad4fe5782c418b2d69e72b5e8c3 100644
--- a/app/config/database.py
+++ b/app/config/database.py
@@ -1,17 +1,28 @@
# -*- coding: utf-8 -*-
from .redis import *
database['type']='mysql' # 数据库类型 目前支持mysql和sqlite
-database['debug']=True #是否开启数据库调试描述
+database['debug']=False #是否开启数据库调试描述
database['host']=['127.0.0.1']#服务器地址 [地址1,地址2,地址3...] 多个地址分布式(主从服务器)下有效
database['port']=[3306] #端口 [端口1,端口2,端口3...]
database['user']=['root'] #用户名 [用户名1,用户名2,用户名3...]
database['password']=['root'] #密码 [密码1,密码2,密码3...]
database['db']=['test'] #数据库名 [数据库名1,数据库名2,数据库名3...]
-database['charset']='utf8' #数据库编码默认采用utf8
+database['charset']='utf8mb4' #数据库编码默认采用utf8mb4
database['pattern']=False # True数据库长连接模式 False数据库短连接模式 注:建议web应用有效,cli应用方式下,如果长时间运行建议使用mysql().close()关闭
database['cli']=False # 是否以cli方式运行
database['dbObjcount']=1 # 连接池数量(单个数据库地址链接数量),数据库链接实例数量 mysql长链接模式下有效
database['deploy']=0 # 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) mysql数据库有效
database['master_num']=1 #主服务器数量 不能超过host服务器数量 (等于服务器数量表示读写不分离:主主复制。 小于服务器表示读写分离:主从复制。) mysql数据库有效
database['master_dql']=False #主服务器是否可以执行dql语句 是否可以执行select语句 主服务器数量大于等于host服务器数量时必须设置True
-database['break']=0 #断线重连次数,0表示不重连。 注:cli模式下 10秒进行一次重连并且连接次数是当前配置的300倍
\ No newline at end of file
+database['break']=0 #断线重连次数,0表示不重连。 注:cli模式下 10秒进行一次重连并且连接次数是当前配置的300倍
+
+#mongodb配置
+mongo['host']='127.0.0.1'
+mongo['port']='27017'
+mongo['user']=''
+mongo['password']=''
+mongo['db']='test'
+mongo['retryWrites']=False #是否支持重新写入
+
+#sqlite配置
+sqlite['db']='kcwlicuxweb' #sqlite数据库文件
\ No newline at end of file
diff --git a/app/index/README.md b/app/index/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..32dce566980cfe80d93c55d01b7b0815b23cc126
--- /dev/null
+++ b/app/index/README.md
@@ -0,0 +1 @@
+kcweb公共模块
\ No newline at end of file
diff --git a/app/index/__init__.py b/app/index/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..72f4562d7cd39f3714c594f3aa34d0cd5cd9c7b9
--- /dev/null
+++ b/app/index/__init__.py
@@ -0,0 +1 @@
+from . import controller
\ No newline at end of file
diff --git a/app/index/common/__init__.py b/app/index/common/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..6b23e23a4f1cc8bc65212a2415b4e9c9923fe3d8
--- /dev/null
+++ b/app/index/common/__init__.py
@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from .autoload import *
\ No newline at end of file
diff --git a/app/index/common/autoload.py b/app/index/common/autoload.py
new file mode 100644
index 0000000000000000000000000000000000000000..fe233919111e09f728bbf122b2bc372bccd1e726
--- /dev/null
+++ b/app/index/common/autoload.py
@@ -0,0 +1 @@
+from app.common import *
\ No newline at end of file
diff --git a/app/index/common/file/sqlite/.gitignore b/app/index/common/file/sqlite/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..0179ab13c5a4f4c0c82ae8b30df046ed2556abdb
--- /dev/null
+++ b/app/index/common/file/sqlite/.gitignore
@@ -0,0 +1 @@
+intapp
\ No newline at end of file
diff --git a/app/index/controller/__init__.py b/app/index/controller/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..6a0389200c3dbfe0c77443814666268ed08060c3
--- /dev/null
+++ b/app/index/controller/__init__.py
@@ -0,0 +1,2 @@
+
+from . import index
\ No newline at end of file
diff --git a/app/index/controller/index/README.md b/app/index/controller/index/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..b853e39e43ee925a2e15497b3cfdd51786ee231b
--- /dev/null
+++ b/app/index/controller/index/README.md
@@ -0,0 +1 @@
+kcweb内置用户管理插件 包括登录 管理员管理等
\ No newline at end of file
diff --git a/app/index/controller/index/__init__.py b/app/index/controller/index/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..3471b9b2359f2a4e9c365ec5dff7186de9623922
--- /dev/null
+++ b/app/index/controller/index/__init__.py
@@ -0,0 +1 @@
+from . import index
\ No newline at end of file
diff --git a/app/index/controller/index/common/__init__.py b/app/index/controller/index/common/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..60767acb1935b5b933b889bf3903da2c5caae055
--- /dev/null
+++ b/app/index/controller/index/common/__init__.py
@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from .model import *
\ No newline at end of file
diff --git a/app/index/controller/index/common/autoload.py b/app/index/controller/index/common/autoload.py
new file mode 100644
index 0000000000000000000000000000000000000000..ca177e97a4924892d1827cdb863baac58947a9ef
--- /dev/null
+++ b/app/index/controller/index/common/autoload.py
@@ -0,0 +1 @@
+from app.index.common import *
\ No newline at end of file
diff --git a/app/index/controller/index/common/file/sqlite/.gitignore b/app/index/controller/index/common/file/sqlite/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..72a3e83b95c3b825bfa74389fa7962abef8cf27f
--- /dev/null
+++ b/app/index/controller/index/common/file/sqlite/.gitignore
@@ -0,0 +1 @@
+intappindex
\ No newline at end of file
diff --git a/app/index/controller/index/common/model.py b/app/index/controller/index/common/model.py
new file mode 100644
index 0000000000000000000000000000000000000000..9a154382ed6d3218a94297365862a8bebd0b7992
--- /dev/null
+++ b/app/index/controller/index/common/model.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+from .autoload import *
+# 可以在这里初始化数据库
+model_intapp_index_path=os.path.split(os.path.realpath(__file__))[0]+"/file/sqlite/intappindex" #数据存放目录
diff --git a/app/index/controller/index/index.py b/app/index/controller/index/index.py
new file mode 100644
index 0000000000000000000000000000000000000000..a4fb861361f1f817008ff12a681de238118b0743
--- /dev/null
+++ b/app/index/controller/index/index.py
@@ -0,0 +1,27 @@
+from .common import *
+def before_request():
+ pass
+def index():
+ return "默认模块"
+def outlogin():
+ account_token=request.args.get("account_token")
+ if account_token:
+ del_cache(account_token)
+ else:
+ del_session('userinfo')
+ return successjson()
+def get_account_token(username,sign,timestamp,random,types="get_account_token"):
+ "获取用户token"
+ status,code,msg,account_token=serlogin(username,sign,timestamp,random,types)
+ if status:
+ return successjson(data={"account_token":account_token},msg=msg)
+ else:
+ return errorjson(code=code,msg=msg)
+def login(username,sign,timestamp,random,types="session"):
+ "登录"
+ status,code,msg,account_token=serlogin(username,sign,timestamp,random,types)
+ if status:
+ return successjson(data=account_token,msg=msg)
+ else:
+ return errorjson(code=code,msg=msg)
+
diff --git a/app/index/controller/index/install.txt b/app/index/controller/index/install.txt
new file mode 100644
index 0000000000000000000000000000000000000000..fde6665e72eab0f28b090d94afdba781c4db892f
--- /dev/null
+++ b/app/index/controller/index/install.txt
@@ -0,0 +1 @@
+kcweb
\ No newline at end of file
diff --git a/app/index/controller/index/tpl/index/home.html b/app/index/controller/index/tpl/index/home.html
new file mode 100644
index 0000000000000000000000000000000000000000..beca5716b718bd6c0160f4b4c2e154c1b092e8af
--- /dev/null
+++ b/app/index/controller/index/tpl/index/home.html
@@ -0,0 +1,51 @@
+
+
+
+
+${title}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${content}
+
+
+
+
diff --git a/app/index/controller/index/tpl/index/index.html b/app/index/controller/index/tpl/index/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..beca5716b718bd6c0160f4b4c2e154c1b092e8af
--- /dev/null
+++ b/app/index/controller/index/tpl/index/index.html
@@ -0,0 +1,51 @@
+
+
+
+
+${title}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${content}
+
+
+
+
diff --git a/app/index/install.txt b/app/index/install.txt
new file mode 100644
index 0000000000000000000000000000000000000000..fde6665e72eab0f28b090d94afdba781c4db892f
--- /dev/null
+++ b/app/index/install.txt
@@ -0,0 +1 @@
+kcweb
\ No newline at end of file
diff --git a/app/intapp/controller/__init__.py b/app/intapp/controller/__init__.py
index 6a0389200c3dbfe0c77443814666268ed08060c3..90b3d0450033971e101e374870a5df94f4fc9a87 100644
--- a/app/intapp/controller/__init__.py
+++ b/app/intapp/controller/__init__.py
@@ -1,2 +1,12 @@
+import re
+def error(e,data):
+ try:
+ plug=str(e).split("has no attribute")[1]
+ plug=re.sub("[' ]","",plug)
+ except:
+ plug=''
+ header={"Content-Type":"application/json; charset=utf-8","Access-Control-Allow-Origin":"*"}
+ header['Location']="/intapp/index/plug/index/intapp/"+plug
+ return '{"code":1,"msg":"您访问的地址不存在","data":"'+str(e)+'"}','302 Found',header
from . import index
\ No newline at end of file
diff --git a/app/intapp/controller/index/admin.py b/app/intapp/controller/index/admin.py
index 77c27d8c1ae793ede8231de40320aef43fe0943a..d2b4fee2bb08ecc42bec31ea562bda93d51e8092 100644
--- a/app/intapp/controller/index/admin.py
+++ b/app/intapp/controller/index/admin.py
@@ -1,8 +1,14 @@
from .common import *
def index():
- return response.tpl()
+ if sysisphone():
+ return response.tpl("../tplm/admin/index")
+ else:
+ return response.tpl()
def role():
- return response.tpl()
+ if sysisphone():
+ return response.tpl("../tplm/admin/role")
+ else:
+ return response.tpl()
def getpluglist(modular="intapp"):
"本地插件列表"
path="app/"+modular+"/controller/"
@@ -17,11 +23,14 @@ def getpluglist(modular="intapp"):
for k in data:
# k['value']=k['modular']+"/"+k['name']
data[i]['role']=json_decode(k['role'])
- if k['name'] not in lists:
- # print(k['name'],lists)
- del data[i]
+ # if k['name'] not in lists:
+ # # print(k['name'],lists)
+ # del data[i]
i+=1
return successjson(data)
+def dellogin():
+ shutil.rmtree(config.session['path'])
+ return successjson()
def getlist(id=0):
"获取列表"
if id:
@@ -55,17 +64,21 @@ def insert():
return errorjson(msg="失败")
else:
return successjson()
-def delete():
+def delete(id=0):
"批量删除"
- try:
- id=request.get_json()
- if 1 in id:
- id.remove(1)
- sqlite("admin",model_app_path).where('id','in',id).delete()
- except:
- return errorjson(msg="失败")
- else:
+ if id:
+ sqlite("admin",model_app_path).where('id',id).delete()
return successjson()
+ else:
+ try:
+ id=request.get_json()
+ if 1 in id:
+ id.remove(1)
+ sqlite("admin",model_app_path).where('id','in',id).delete()
+ except:
+ return errorjson(msg="失败")
+ else:
+ return successjson()
def update(id=0):
"更新内容"
data=request.get_json()
@@ -80,7 +93,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 +161,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/autoload.py b/app/intapp/controller/index/common/autoload.py
index e9ece292743d0144070d5c40ff89b122bedcc736..a98a5a139aafc5d2336b255878a033b15f33f652 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 26bc1f21968e60e5602013607d12c43f16aeff5a..dc6467ec11edb3f067a3a4f2dd1b2360230ed6e0 100644
--- a/app/intapp/controller/index/common/model.py
+++ b/app/intapp/controller/index/common/model.py
@@ -33,28 +33,26 @@ 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_pythonrun(modelsqliteintapp):
+ "项目运行管理"
+ table="pythonrun"
+ 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=''),
+ "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('pythonrun',model_intapp_index_path).find()
+except:
+ 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/index.py b/app/intapp/controller/index/index.py
index 9305d5d5f6c96b19652a0461bd5db2568467b520..cd231a5b88cb9fcc811d1f7dadea8ac3357fc431 100644
--- a/app/intapp/controller/index/index.py
+++ b/app/intapp/controller/index/index.py
@@ -1,14 +1,23 @@
from .common import *
import psutil
def index():
- return response.tpl(userinfo=G.userinfo)
+ if os.path.isfile("app/common/file/config.conf"):
+ data=json_decode(file_get_content("app/common/file/config.conf"))
+ else:
+ data={
+ 'system':{
+ "logo":"","name":""
+ }
+ }
+ if sysisphone():
+ return response.tpl("../tplm/index/index",userinfo=G.userinfo,fileconfig=data)
+ else:
+ return response.tpl(userinfo=G.userinfo,fileconfig=data)
def home():
- return response.tpl()
-# def pub(html):
-# return response.tpl("pub/%s" % html)
-# def s(fun,html):
-# return response.tpl("%s/%s" % (fun,html))
-
+ if sysisphone():
+ return response.tpl("../tplm/index/home")
+ else:
+ return response.tpl()
def menu():
admin_id=G.userinfo['id']
data={
diff --git a/app/intapp/controller/index/install.txt b/app/intapp/controller/index/install.txt
index 8116b777919a1815a4f0ac3ffc14c0e95974867a..3f68567f72dd3319433bc4a64a052e7074fd8bb3 100644
--- a/app/intapp/controller/index/install.txt
+++ b/app/intapp/controller/index/install.txt
@@ -1,2 +1,6 @@
+kcweb>=4.12.0
+gunicorn==20.0.4
+apscheduler==3.6.3
+psutil==5.7.0
pexpect==4.8.0
-psutil==5.7.0
\ No newline at end of file
+oss2==2.12.1
\ No newline at end of file
diff --git a/app/intapp/controller/index/menu.py b/app/intapp/controller/index/menu.py
index 91c040bc11ada642c6c9065c7a2a9a18eb582ef9..652280694cbc9dbc60b4ea5964b89c165a71200f 100644
--- a/app/intapp/controller/index/menu.py
+++ b/app/intapp/controller/index/menu.py
@@ -1,7 +1,10 @@
from .common import *
import base64,psutil
def index():
- return response.tpl()
+ if sysisphone():
+ return response.tpl("../tplm/menu/index")
+ else:
+ return response.tpl()
def menulist(pid=0):
pagenow=request.args.get('pagenow')
pagesize=request.args.get('pagesize')
@@ -37,7 +40,7 @@ def menudelete():
idstr="0"
for k in id:
idstr+=","+str(k)
- sqlite("menu",model_app_path).where("id in ("+idstr+") and admin_id != 0").delete()
+ sqlite("menu",model_app_path).where("id in ("+idstr+")").delete()
return successjson()
def menuinsert():
data=request.get_json()
diff --git a/app/intapp/controller/index/modular.py b/app/intapp/controller/index/modular.py
index 561a24e6eda50076e0e40b83c00bbaac7ff7a79a..c2b24990c8d89ffcaeaa710dd33483cf2ac6c929 100644
--- a/app/intapp/controller/index/modular.py
+++ b/app/intapp/controller/index/modular.py
@@ -1,7 +1,10 @@
from .common import *
kcwebuserinfopath=os.path.split(os.path.realpath(__file__))[0]+"/common/file/"
def index():
- return response.tpl()
+ if sysisphone():
+ return response.tpl("../tplm/modular/index")
+ else:
+ return response.tpl()
if not os.path.exists(kcwebuserinfopath):
os.makedirs(kcwebuserinfopath)
def kcwebsebduser():
@@ -37,11 +40,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",params={
"kw":kw,"pagenow":pagenow
})
res=json_decode(http.get_text)
- del http
lists=res['data']['lists']
for k in lists:
k['status']=0 #0未安装 1已安装 2安装中 3卸载中 4不可以安装
diff --git a/app/intapp/controller/index/plan.py b/app/intapp/controller/index/plan.py
index 3744e20eac9cbaafdbf6838c873d57266ca55ffa..1dbad6d2aa856682393db2884b1907508d01b9a4 100644
--- a/app/intapp/controller/index/plan.py
+++ b/app/intapp/controller/index/plan.py
@@ -3,7 +3,10 @@
from .common import *
indexconfigpath=os.path.split(os.path.realpath(__file__))[0]+"/common/file/sqlite/"
def index():
- return response.tpl()
+ if sysisphone():
+ return response.tpl("../tplm/plan/index")
+ else:
+ return response.tpl()
def get(id=0):
"获取列表"
if id:
diff --git a/app/intapp/controller/index/plug.py b/app/intapp/controller/index/plug.py
index 0ffdfc9834a2293ddfbe1570cb6d627d53475723..4589076a4eec45c157a75e483ef7488a50d651c6 100644
--- a/app/intapp/controller/index/plug.py
+++ b/app/intapp/controller/index/plug.py
@@ -1,7 +1,19 @@
from .common import *
kcwebuserinfopath=os.path.split(os.path.realpath(__file__))[0]+"/common/file/"
-def index(modular="intapp"):
- return response.tpl(modular=modular)
+def index(modular="intapp",kw=''):
+ lefttext=request.args.get('lefttext')
+ if not lefttext:
+ lefttext='应用'
+ lefturl=request.args.get('lefturl')
+ if not lefturl:
+ lefturl='myapp'
+ lefttype=request.args.get('lefttype')
+ if not lefttype:
+ lefttype=''
+ if sysisphone():
+ return response.tpl("../tplm/plug/index",modular=modular,kw=kw,lefttext=lefttext,lefturl=lefturl,lefttype=lefttype)
+ else:
+ return response.tpl(modular=modular,kw=kw)
def getpluglist(modular="intapp"):
"本地插件列表"
path="app/"+modular+"/controller/"
@@ -17,13 +29,14 @@ 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","POST",{
- "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)
res=json_decode(http.get_text)
del http
lists=res['data']['lists']
diff --git a/app/intapp/controller/index/pub.py b/app/intapp/controller/index/pub.py
index 0ea49c27a6c0eadca21e582e5c5e26e9f4f2a1c2..bfbd2ae6cfae3b48c6607165b5c5a9818a73c995 100644
--- a/app/intapp/controller/index/pub.py
+++ b/app/intapp/controller/index/pub.py
@@ -1,6 +1,5 @@
from .common import *
import subprocess,pexpect
-
def before_request():
pass
def checkserver():
diff --git a/app/intapp/controller/index/role.txt b/app/intapp/controller/index/role.txt
index 9707eaa56901ef7a50bba1098713950af1e5c26f..9add180e0264d63722c38ef7ea3faf715bc7c11b 100644
--- a/app/intapp/controller/index/role.txt
+++ b/app/intapp/controller/index/role.txt
@@ -50,21 +50,28 @@ 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/pythonrun
+启动/停止项目管理,/intapp/index/setup/restart
+设置/添加项目管理,/intapp/index/setup/setpythonrun
+删除项目管理,/intapp/index/setup/delpythonrun
+项目管理列表,/intapp/index/setup/pythonrulists
+项目管理日志,/intapp/index/setup/logpythonrun
+获取/保存配置信息,/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 fd057570c22956b91abf023151ae12efd43a208e..0aa83a584873307b8ccbbd0e88208e9595497394 100644
--- a/app/intapp/controller/index/setup.py
+++ b/app/intapp/controller/index/setup.py
@@ -1,13 +1,185 @@
from .common import *
import base64,oss2
def index():
- return response.tpl()
+ if sysisphone():
+ return response.tpl("../tplm/setup/index")
+ else:
+ return response.tpl()
+def basepage():
+ "基本配置"
+ if sysisphone():
+ return response.tpl("../tplm/setup/basepage")
+ else:
+ return response.tpl()
+def startpage():
+ "开机启动项"
+ if sysisphone():
+ return response.tpl("../tplm/setup/startpage")
+ else:
+ return response.tpl()
+def bacrecpage():
+ "备份恢复页面"
+ if sysisphone():
+ return response.tpl("../tplm/setup/bacrecpage")
+ else:
+ return response.tpl()
+def pythonrun():
+ "项目管理器"
+ if sysisphone():
+ return response.tpl("../tplm/setup/pythonrun")
+ else:
+ return response.tpl()
+def restart(types='stop'):
+ "启动/停止项目管理"
+ data=request.get_json()
+ interpreter=md5(data['paths']+data['types']+data['filename']+data['other']) #解释器
+ if types=='start':
+ if data['types']=='python3.6':
+ if not os.path.isfile("/usr/bin/"+interpreter):
+ os.system("ln -s /usr/local/python/python3.6/bin/python3 /usr/bin/"+interpreter)
+ elif data['types']=='php7.2':
+ if os.path.isfile("/usr/local/php/php7.2/bin/php"):
+ os.system("ln -s /usr/local/php/php7.2/bin/php /usr/bin/"+interpreter)
+ else:
+ return errorjson(msg="您必须使用本系统的软件插件安装php7.2后才能使用该功能")
+ elif data['types']=='php7.3':
+ if os.path.isfile("/usr/local/php/php7.3/bin/php"):
+ os.system("ln -s /usr/local/php/php7.3/bin/php /usr/bin/"+interpreter)
+ else:
+ return errorjson(msg="您必须使用本系统的软件插件安装php7.3后才能使用该功能")
+ if data['other']: #带运行参数
+ os.system("cd "+data['paths']+"&& nohup "+interpreter+" "+data['filename']+" "+data['other']+" > "+data['paths']+"/"+interpreter+".log 2>&1 &")
+ else:
+ os.system("cd "+data['paths']+"&& nohup "+interpreter+" "+data['filename']+" > "+interpreter+".log 2>&1 &")
+ time.sleep(1)
+ if get_process_id(interpreter):
+ return successjson()
+ else:
+ return errorjson(msg="启动失败")
+ elif types=='stop':
+ os.system("pkill -9 "+interpreter[:12])
+ return successjson()
+def setpythonrun():
+ "设置/添加项目管理"
+ if 'Linux' in get_sysinfo()['platform']:
+ data=request.get_json()
+
+ interpreter=md5(data['paths']+data['types']+data['filename']+data['other']) #解释器
+ if not os.path.isfile("/usr/bin/"+interpreter):
+ if data['types']=='python3.6':
+ os.system("ln -s /usr/local/python/python3.6/bin/python3 /usr/bin/"+interpreter)
+ elif data['types']=='php7.2':
+ if os.path.isfile("/usr/local/php/php7.2/bin/php"):
+ os.system("ln -s /usr/local/php/php7.2/bin/php /usr/bin/"+interpreter)
+ else:
+ return errorjson(msg="您必须使用本系统的软件插件安装php7.2后才能使用该功能")
+ elif data['types']=='php7.3':
+ if os.path.isfile("/usr/local/php/php7.3/bin/php"):
+ os.system("ln -s /usr/local/php/php7.3/bin/php /usr/bin/"+interpreter)
+ else:
+ return errorjson(msg="您必须使用本系统的软件插件安装php7.3后才能使用该功能")
+ if data['other']: #带运行参数
+ os.system("cd "+data['paths']+"&& nohup "+interpreter+" "+data['filename']+" "+data['other']+" > "+data['paths']+"/"+interpreter+".log 2>&1 &")
+ else:
+ os.system("cd "+data['paths']+"&& nohup "+interpreter+" "+data['filename']+" > "+data['paths']+"/"+interpreter+".log 2>&1 &")
+ 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']+arr['other']) #解释器
+ if interpreterj!=interpreter:#删除之前的
+ os.system("pkill -9 "+interpreterj[:12])
+ os.remove("/usr/bin/"+interpreterj)
+ data.update(updtime=times(),addtime=times())
+ del data['status']
+ 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(interpreter)
+ else:
+ return errorjson(msg="不支持该系统,当前只支持linux")
+def logpythonrun(id):
+ "项目管理日志"
+ arr=sqlite("pythonrun").where('id',id).find()
+ interpreter=md5(arr['paths']+arr['types']+arr['filename']+arr['other']) #解释器
+ data=file_get_content(arr['paths']+"/"+interpreter+".log")
+ return successjson(data)
+def delpythonrun(id=''):
+ "删除项目管理"
+ try:
+ if id:
+ id=[id]
+ else:
+ id=request.get_json()
+ arr=sqlite("pythonrun").where('id','in',id).field("paths,types,filename,other").select()
+ for k in arr:
+ interpreter=md5(k['paths']+k['types']+k['filename']+k['other']) #解释器
+ os.system("pkill -9 "+interpreter[:12])
+ if os.path.isfile("/usr/bin/"+interpreter):
+ os.remove("/usr/bin/"+interpreter)
+ sqlite("pythonrun").where('id','in',id).delete()
+ except:
+ return errorjson(msg="失败")
+ else:
+ return successjson()
+def pythonrulists(id=''):
+ "项目管理列表"
+ if id:
+ return successjson(sqlite("pythonrun").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("pythonrun").where(where).page(pagenow,pagesize).select()
+ for k in lists:
+ interpreter=md5(k['paths']+k['types']+k['filename']+k['other']) #解释器
+ 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'):
+ "保存配置信息"
+ 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()
if sqlite("start").connect(model_app_path).where("value",data['value']).count():
return errorjson(msg="禁止重复添加")
- if system_start.insert_Boot_up(cmd=data['value'],name=data['name'],types=data['types'],admin_id=G.userinfo['id']):
+ try:
+ icon=data['icon']
+ except:
+ icon=''
+ if system_start.insert_Boot_up(cmd=data['value'],name=data['name'],types=data['types'],admin_id=G.userinfo['id'],icon=icon):
return successjson()
else:
return errorjson(msg="添加失败,该系统支不支持")
@@ -33,24 +205,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=='app':
+ 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"))
@@ -61,10 +228,18 @@ def aliyunosslist():
for obj in oss2.ObjectIterator(bucket, prefix = prefix, delimiter = '/'):
# 通过is_prefix方法判断obj是否为文件夹。
if obj.is_prefix(): # 文件夹
- data.append({"name":obj.key.split("/")[-2],"path":obj.key,"type":"folder"})
+ data.insert(0,{"name":obj.key.split("/")[-2],"path":obj.key,"type":"folder"})
else: # 文件
- data.append({"name":obj.key.split("/")[-1],"path":obj.key,"type":"file"})
+ data.insert(0,{"name":obj.key.split("/")[-1],"path":obj.key,"type":"file"})
except:pass
+ # data1=[]
+ # i=len(data)
+ # while True:
+ # i+=1
+ # if i<0:
+ # break
+ # else:
+ # data1.append(data[i])
return successjson(data)
def aliyunossdownload(types=""):
"从阿里云备份点恢复"
@@ -92,15 +267,19 @@ def aliyunossdownload(types=""):
return successjson()
def backup(types=''):
"备份全部"
- filelist=get_file("app")
- if os.path.exists("backup"):
- shutil.rmtree("backup")
- for k in filelist:
- if k['type']=='folder' and '__pycache__' not in k['path']:
- if 'common/file' == k['path'][-11:]:
- shutil.copytree(k['path'],"backup/"+k['path'])
+ paths=request.args.get("paths")
+ if paths: #备份目录 app/common/file
+ shutil.copytree(paths,"backup/"+paths)
+ else: #备份全部
+ filelist=get_file("app")
+ if os.path.exists("backup"):
+ shutil.rmtree("backup")
+ for k in filelist:
+ if k['type']=='folder' and '__pycache__' not in k['path']:
+ if 'common/file' == k['path'][-11:]:
+ shutil.copytree(k['path'],"backup/"+k['path'])
+ # print(k['path'],"backup/"+k['path'])
if types=='aliyun':#备份文件上传到阿里云oss
- print("本地备份成功")
if not os.path.isfile("app/common/file/config.conf"):
print("您没有保存阿里云oss修改配置信息而无法上传")
else:
@@ -122,7 +301,7 @@ def backup(types=''):
filelist.append(obj.key)
i=0
while True:
- if len(filelist)-i <= 5: #在阿里云保留5个备份文件
+ if len(filelist)-i <= 30: #在阿里云保留30个备份文件
break
bucket.delete_object(filelist[i])
i+=1
@@ -131,8 +310,11 @@ def backup(types=''):
if not config.app['cli']:
return successjson(msg="所有文稿备份成功")
def recovery():
- "恢复全部文稿"
- if os.path.exists("backup/app"):
+ "恢复文稿"
+ paths=request.args.get("paths")
+ if paths: #恢复指定目录 app/common/file
+ shutil.copytree("backup/"+paths,paths)
+ elif os.path.exists("backup/app"): #恢复全部文稿
filelist=get_file("backup/app")
for k in filelist:
if k['type']=='folder' and '__pycache__' not in k['path']:
@@ -141,7 +323,7 @@ def recovery():
if os.path.exists(path):
shutil.rmtree(path)
shutil.copytree(k['path'],path)
- # print(k['path'],path)
+ print(k['path'],path)
return successjson(msg="所有文稿恢复成功")
else:
return errorjson(msg="备份目录不存在")
@@ -164,3 +346,36 @@ def postsup():
return successjson()
else:
return errorjson(msg="上传失败")
+def dowfile(name=''):
+ "下载指定文件"
+ pathname=request.args.get("pathname")
+ return response.download(pathname)
+def uploadfile():
+ "上传文件导指定目录"
+ pathname=request.args.get("pathname")
+ if request.binary.save('file',pathname):
+ return successjson()
+ else:
+ return errorjson(msg="上传失败")
+def backxz(name=''):
+ "压缩指定文件夹并下载"
+ paths=request.args.get("paths")
+ zip.packzip(paths,"backxz.zip")
+ f=open("backxz.zip","rb")
+ body=f.read()
+ f.close()
+ os.remove("backxz.zip")
+ return body,"200 ok",{"Content-Type":"application/zip","Accept-Ranges":"bytes"}
+def upunback():
+ "上传zip压缩包并解压指定文件夹"
+ paths=request.args.get("paths")
+ if request.binary.save('file',"backxz."+request.binary.filesuffix('file')):
+ try:
+ zip.unzip_file("backxz.zip",paths)
+ os.remove("backxz.zip")
+ except:
+ return errorjson(msg="文件格式错误")
+ return successjson()
+ else:
+ return errorjson(msg="上传失败")
+ return successjson()
diff --git a/app/intapp/controller/index/task.py b/app/intapp/controller/index/task.py
index 1a80e0bb1fa06e40d00a5b91b4eaac962fcd80c9..9dddbf3c3d86d7f14bd4e1fe27a14dbb15c081da 100644
--- a/app/intapp/controller/index/task.py
+++ b/app/intapp/controller/index/task.py
@@ -1,6 +1,9 @@
from .common import *
def index():
- return response.tpl()
+ if sysisphone():
+ return response.tpl("../tplm/task/index")
+ else:
+ return response.tpl()
def task():
pagenow=request.args.get('pagenow')
pagesize=request.args.get('pagesize')
diff --git a/app/intapp/controller/index/tpl/admin/index.html b/app/intapp/controller/index/tpl/admin/index.html
index e87ff5d7b91e8383d34196185c8361628860819f..d1fe2c7f552ff7cf76d87b9631d8f4fe76a6f648 100644
--- a/app/intapp/controller/index/tpl/admin/index.html
+++ b/app/intapp/controller/index/tpl/admin/index.html
@@ -34,7 +34,11 @@
搜索
添加管理员账户
- 角色管理
+
+ 角色管理
+ 清除所有会话
+
+
@@ -90,7 +94,8 @@
-
+
+ 选择图片
@@ -122,6 +127,10 @@