diff --git a/README.md b/README.md
index 125257eb0c0a0f7f604055e6befd273ab3caa9bf..414719163a8050147e111c832a4c02e1b6b2783b 100644
--- a/README.md
+++ b/README.md
@@ -4,4 +4,14 @@
kcweb作为web开发而设计的高性能框架,采用全新的架构思想,注重易用性。遵循MIT开源许可协议发布,意味着个人和企业可以免费使用kcweb,甚至允许把你基于kcweb开发的应用开源或商业产品发布或销售。
-[完整文档](https://intapp.kwebapp.cn/intapp/doc/index/finddoc/5/27/1 "文档")
\ No newline at end of file
+[完整文档](https://intapp.kwebapp.cn/intapp/doc/index/finddoc/5/27/1 "文档")
+
+开发环境下运行命令
+````
+python server.py
+````
+
+生产环境下运行命令
+````
+bash server.sh
+````
\ No newline at end of file
diff --git a/app/common/__init__.py b/app/common/__init__.py
index 76817a776991075da2bc28ce2c2ade7dfc6f8a75..8580b5d09ac078de1281d3167fc6c4dec090622b 100644
--- a/app/common/__init__.py
+++ b/app/common/__init__.py
@@ -153,6 +153,7 @@ def after_request(body,status,resheader):
"routeparam":routeparam,
"getparam":getparam,
"dataparam":dataparam,
+ "remote_addr":request.HEADER.Physical_IP(),
"addtime":times()
})
G.setadminlog=""
@@ -168,11 +169,15 @@ def return_list(lists,count,pagenow,pagesize):
pagesize 每页数量
"""
+ if count:
+ pagecount=math.ceil(int(count)/int(pagesize))
+ else:
+ pagecount=0
data={
- 'count':count,
- 'pagenow':pagenow,
- 'pagesize':pagesize,
- 'pagecount':math.ceil(int(count)/int(pagesize)),
+ 'count':int(count),
+ 'pagenow':int(pagenow),
+ 'pagesize':int(pagesize),
+ 'pagecount':pagecount,
'lists':lists
}
return data
@@ -251,6 +256,7 @@ def file_get_content(filename,encoding=False):
encoding 是否返回文件编码 默认否
"""
fileData=''
+ cur_encoding="utf-8"
if os.path.isfile(filename):
with open(filename, 'rb') as f:
cur_encoding = chardet.detect(f.read())['encoding']
diff --git a/app/common/file/config.conf b/app/common/file/config.conf
index e5c0567887dfa7315c8eda88577f500ddc8fa05b..5c6def80228756a455695f71606453955fb32322 100644
--- a/app/common/file/config.conf
+++ b/app/common/file/config.conf
@@ -1 +1 @@
-{"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
+{"aliyun": {"address": "http://oss-cn-beijing.aliyuncs.com", "bucket": "", "access_key": "", "access_key_secret": "", "backpath": "backup"}, "system": {"name": "kcwebplus-云管", "logo": "https://imgmt.kwebapp.cn/icon/api.png", "kcwebuser": {}}}
\ No newline at end of file
diff --git a/app/common/model.py b/app/common/model.py
index a52aead3c1eaeb9b346403291310bc09424c6596..6ec26a081e8ef18df829eaad58e477208433066a 100644
--- a/app/common/model.py
+++ b/app/common/model.py
@@ -62,6 +62,7 @@ class model_app_admin_log(modelsqliteintapp):
"routeparam":model.dbtype.varchar(LEN=11,DEFAULT=''), #路由参数
"getparam":model.dbtype.varchar(LEN=64,DEFAULT=''), #GET参数
"dataparam":model.dbtype.text(), #body参数
+ "remote_addr":model.dbtype.varchar(LEN=64,DEFAULT=''), #请求物理ip
"addtime":model.dbtype.int(LEN=11,DEFAULT=0) #添加时间
}
try:
diff --git a/app/config/redis.py b/app/config/redis.py
index a690d9a063a5cb327d01c4151e8264815899bdb8..a69f4f4cb18dc6c825e2ebff8461f882298cbc8d 100644
--- a/app/config/redis.py
+++ b/app/config/redis.py
@@ -5,4 +5,5 @@ redis['port']=6379 #端口
redis['password']='' #密码
redis['db']=0 #Redis数据库 注:Redis用0或1或2等表示
redis['pattern']=True # True连接池链接 False非连接池链接
-redis['ex']=0 #过期时间 (秒)
\ No newline at end of file
+redis['ex']=0 #过期时间 (秒)
+
diff --git a/app/index/controller/index/index.py b/app/index/controller/index/index.py
index 9c4abe37d64c25c43c7703b54cada17231e3d430..89af65d3710ff42993f5d17d285a7216c5344d9e 100644
--- a/app/index/controller/index/index.py
+++ b/app/index/controller/index/index.py
@@ -25,4 +25,6 @@ def login(username,sign,timestamp,random,types="session"):
return successjson(data=account_token,msg=msg)
else:
return errorjson(code=code,msg=msg)
+def addr():
+ return successjson(request.HEADER.Physical_IP())
diff --git a/app/intapp/controller/index/admin.py b/app/intapp/controller/index/admin.py
index 50615aa83c641b46df6c0494c813b6cabba6fb9e..0be0a19e1c5b5e0f0bdc9a262a18a6fbe12adb75 100644
--- a/app/intapp/controller/index/admin.py
+++ b/app/intapp/controller/index/admin.py
@@ -1,4 +1,14 @@
from .common import *
+def setadminpwd():
+ "设置初始化用户 登录码和密码"
+ username=times()
+ password="111111"
+ try:
+ sqlite("admin",model_app_path).where("id",1).update({'username':username,'password':md5("kcw"+password)})
+ except:
+ return errorjson(msg="设置失败")
+ else:
+ return successjson({"username":username,"password":password})
def index():
if sysisphone():
return response.tpl("../tplm/admin/index")
diff --git a/app/intapp/controller/index/common/autoload.py b/app/intapp/controller/index/common/autoload.py
index a98a5a139aafc5d2336b255878a033b15f33f652..2947b4a5c7f11794dd994ea6f16136c4fbd013d9 100644
--- a/app/intapp/controller/index/common/autoload.py
+++ b/app/intapp/controller/index/common/autoload.py
@@ -7,4 +7,29 @@ def get_process_id(name):
response = child.communicate()[0]
return [int(pid) for pid in response.split()]
except:
- return []
\ No newline at end of file
+ return []
+def returndate(rundate):
+ if rundate < 60:
+ rundate=str(rundate)+"秒"
+ elif rundate < 60*60:
+ rundate=str(int(rundate/60))+"分钟"+str(int(rundate%60))+"秒"
+ elif rundate < 60*60*24:
+ m=int(rundate%(60*60))
+ if m < 60:
+ rundate=str(int(rundate/(60*60)))+"小时"+str(m)+"秒"
+ elif m <60*60:
+ rundate=str(int(rundate/(60*60)))+"小时"+str(int(m/60))+"分"+str(int(m%60))+"秒"
+ else:
+ m=int(rundate%(60*60*24))
+ if m < 60:
+ rundate=str(int(rundate/(60*60*24)))+"天"+str(m)+"秒"
+ elif m < 60*60:
+ rundate=str(int(rundate/(60*60*24)))+"天"+str(int(m/60))+"分"+str(int(m%60))+"秒"
+ elif m < 60*60*24:
+ xs=int(m/3600)
+ mm=int(m%3600)
+ if mm < 60:
+ rundate=str(int(rundate/(60*60*24)))+"天"+str(xs)+"小时"+str(mm)+"秒"
+ else:
+ rundate=str(int(rundate/(60*60*24)))+"天"+str(xs)+"小时"+str(int(mm/60))+"分"+str(int(mm%60))+"秒"
+ return rundate
\ No newline at end of file
diff --git a/app/intapp/controller/index/index.py b/app/intapp/controller/index/index.py
index 8adf3acfcfe1f0ab0cc8e88e32bdd084f4f7d4d3..25f4344819bdcde13e6ec5d263f62c632a2d910b 100644
--- a/app/intapp/controller/index/index.py
+++ b/app/intapp/controller/index/index.py
@@ -25,35 +25,56 @@ def menu():
'leftlist':list_to_tree(data=sqlite("menu",model_app_path).order("sort desc").where("types='left' and (admin_id=0 or admin_id="+str(admin_id)+")").select(),child="level")
}
return successjson(data)
+def ip_Place(client_ip):
+ """ip归属地查询,目前只支持中国地区解析
+ client_ip 客户端ip地址
+
+ return (国家,省,市,县,区,运营商,网络类型)
+ """
+ data=get_cache("intappindexindexip_Place"+client_ip)
+ if not data:
+ http=Http()
+ # if proxip:
+ # http.set_proxies={'http': 'http://'+proxip,'https': 'http://'+proxip}
+ http.set_encoding="gb2312"
+ http.set_session=False
+ http.set_header['Host']='www.ip138.com'
+ http.set_header['User-Agent']='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0'
+ http.openurl("https://www.ip138.com/iplookup.asp?ip=%s&action=2" % client_ip,allow_redirects=False)
+ strs=http.get_text
+ file_set_content("aa.log",strs)
+ strs=strs.split('var ip_result = ')[1]
+ strs=strs.split(";")[0]
+ strs=re.sub(", }","}",strs)
+ ar=json_decode(strs)
+ file_set_content("aa.log",strs)
+ # print(strs)
+ # print(ar)
+ data={
+ "country":"","province":"","city":"","county":"","area":"","operators":"","net":""
+ }
+ if ar and len(ar['ip_c_list']):
+ jsar=ar['ip_c_list'][0]
+ if jsar['city']=='':
+ try:
+ jsar['city']=(ar['参考数据2'].split("省")[1]).split(" ")[0]
+ except:pass
+ jsar['prov']=re.sub("[省,市]","",jsar['prov'])
+ jsar['city']=re.sub("[省,市]","",jsar['city'])
+ lists=[jsar['ct'],jsar['prov'],jsar['city'],jsar['area'],jsar['idc'],jsar['yunyin'],jsar['net']]
+ data={
+ "country":jsar['ct'],"province":jsar['prov'],"city":jsar['city'],"county":jsar['area'],"area":jsar['idc'],"operators":jsar['yunyin'],"net":jsar['net']
+ }
+ set_cache("intappindexindexip_Place"+client_ip,data,86400)
+ return successjson(data)
def homes():
sysinfo=get_sysinfo()
rundate=times()-int(sysinfo['start_time'])
- if rundate < 60:
- rundate=str(rundate)+"秒"
- elif rundate < 60*60:
- rundate=str(int(rundate/60))+"分钟"+str(int(rundate%60))+"秒"
- elif rundate < 60*60*24:
- m=int(rundate%(60*60))
- if m < 60:
- rundate=str(int(rundate/(60*60)))+"小时"+str(m)+"秒"
- elif m <60*60:
- rundate=str(int(rundate/(60*60)))+"小时"+str(int(m/60))+"分"+str(int(m%60))+"秒"
- else:
- m=int(rundate%(60*60*24))
- if m < 60:
- rundate=str(int(rundate/(60*60*24)))+"天"+str(m)+"秒"
- elif m < 60*60:
- rundate=str(int(rundate/(60*60*24)))+"天"+str(int(m/60))+"分"+str(int(m%60))+"秒"
- elif m < 60*60*24:
- xs=int(m/3600)
- mm=int(m%3600)
- if mm < 60:
- rundate=str(int(rundate/(60*60*24)))+"天"+str(xs)+"小时"+str(mm)+"秒"
- else:
- rundate=str(int(rundate/(60*60*24)))+"天"+str(xs)+"小时"+str(int(mm/60))+"分"+str(int(mm%60))+"秒"
- sysinfo['rundate']=rundate
+ sysrundate=times()-int(psutil.boot_time())
+ sysinfo['rundate']=returndate(rundate)
+ sysinfo['sysrundate']=returndate(sysrundate)
return successjson(sysinfo)
def disk():#磁盘分区和使用情况
partition=[]
diff --git a/app/intapp/controller/index/pub.py b/app/intapp/controller/index/pub.py
index bb1d152b1adf884c6e09d3f87a5e8dfa02d5968d..b4b667b79ec0c7c0c5c6ff1b43207a10277c0944 100644
--- a/app/intapp/controller/index/pub.py
+++ b/app/intapp/controller/index/pub.py
@@ -45,7 +45,7 @@ def gitpull():
branch=request.args.get('branch') #强制更新指定分支
title=request.args.get('title')
if not title:
- title="执行命令 git pull 命令"
+ title="执行命令 git pull 命令到"+path
if 'Linux' in get_sysinfo()['platform']:
shell='cd '+path+' && git reset --hard'
if branch:
diff --git a/app/intapp/controller/index/setup.py b/app/intapp/controller/index/setup.py
index 51265e75d553031e81d1718238f83ae47d0b4bd6..c532d5781df8434857a6e1310d8b2d0dc5a0ea7c 100644
--- a/app/intapp/controller/index/setup.py
+++ b/app/intapp/controller/index/setup.py
@@ -206,7 +206,7 @@ def startlist():
else:
pagenow=int(pagenow)
if not pagesize:
- pagesize=10
+ pagesize=100
else:
pagesize=int(pagesize)
yz=system_start.lists(pagenow,pagesize)
diff --git a/app/intapp/controller/index/tpl/admin/admin.html b/app/intapp/controller/index/tpl/admin/admin.html
index 52c5c770b650bfe83b491992c96df5465a21bae4..ef6bb2a7f068d4b45255ce8b05c305449338d9f2 100644
--- a/app/intapp/controller/index/tpl/admin/admin.html
+++ b/app/intapp/controller/index/tpl/admin/admin.html
@@ -6,19 +6,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+<%include file="../include/static.html"/>