pull/109/head
midoks 7 years ago
parent a2217b1b28
commit 09cb564218
  1. 36
      class/public.py
  2. 14
      data/type.json
  3. 2
      plugins/nginx/info.json
  4. 6
      plugins/php/info.json
  5. 2
      plugins/vpn/info.json
  6. 25
      views/plugins.py

@ -4,6 +4,15 @@ import os
import sys
import time
import string
import json
import hashlib
import shlex
import datetime
import subprocess
import re
from random import Random
from flask import jsonify
def getRunDir():
@ -31,7 +40,7 @@ def GetFileMd5(filename):
# 文件的MD5值
if not os.path.isfile(filename):
return False
import hashlib
myhash = hashlib.md5()
f = file(filename, 'rb')
while True:
@ -45,7 +54,6 @@ def GetFileMd5(filename):
def GetRandomString(length):
# 取随机字符串
from random import Random
str = ''
chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'
chrlen = len(chars) - 1
@ -57,7 +65,6 @@ def GetRandomString(length):
def checkCode(code, outime=120):
# 校验验证码
import time
import web
try:
if md5(code.lower()) != web.ctx.session.codeStr:
@ -72,6 +79,10 @@ def checkCode(code, outime=120):
return False
def retJson(status, msg, data=()):
return jsonify({'status': status, 'msg': msg, 'data': data})
def returnJson(status, msg, args=()):
# 取通用Json返回
return getJson(returnMsg(status, msg, args))
@ -94,7 +105,6 @@ def returnMsg(status, msg, args=()):
def getMsg(key, args=()):
# 取提示消息
try:
import json
logMessage = json.loads(
readFile('static/language/' + get_language() + '/public.json'))
keys = logMessage.keys()
@ -111,7 +121,7 @@ def getMsg(key, args=()):
def getLan(key):
# 取提示消息
import json
logMessage = json.loads(
readFile('static/language/' + get_language() + '/template.json'))
keys = logMessage.keys()
@ -221,11 +231,9 @@ def httpPost(url, data, timeout=30):
#WriteLog('网络诊断',str(ex) + '['+url+']');
return str(ex)
# 写进度
def writeSpeed(title, used, total, speed=0):
import json
# 写进度
if not title:
data = {'title': None, 'progress': 0,
'total': 0, 'used': 0, 'speed': 0}
@ -236,11 +244,9 @@ def writeSpeed(title, used, total, speed=0):
writeFile('/tmp/panelSpeed.pl', json.dumps(data))
return True
# 取进度
def getSpeed():
import json
# 取进度
data = readFile('/tmp/panelSpeed.pl')
if not data:
data = json.dumps({'title': None, 'progress': 0,
@ -250,10 +256,6 @@ def getSpeed():
def ExecShell(cmdstring, cwd=None, timeout=None, shell=True):
import shlex
import datetime
import subprocess
import time
if shell:
cmdstring_list = cmdstring
@ -396,11 +398,9 @@ def getStrBetween(startStr, endStr, srcStr):
return None
return srcStr[start + 1:end]
# 取CPU类型
def getCpuType():
import re
# 取CPU类型
cpuinfo = open('/proc/cpuinfo', 'r').read()
rep = "model\s+name\s+:\s+(.+)"
tmp = re.search(rep, cpuinfo)

@ -10,13 +10,23 @@
"ps":""
},
{
"title":"系统工具",
"title":"缓存软件",
"type":2,
"ps":""
},
{
"title":"其他插件",
"title":"代码管理",
"type":3,
"ps":""
},
{
"title":"系统工具",
"type":4,
"ps":""
},
{
"title":"其他插件",
"type":5,
"ps":""
}
]

@ -5,7 +5,7 @@
"type":"其他插件",
"ps":"轻量级,占有内存少,并发能力强",
"shell":"install.sh",
"checks":"/www/server/panel/plugin/safelogin",
"checks":"/www/server/panel/plugin/nginx",
"author":"伊戈尔·赛索耶夫",
"home":"https://www.nginx.org",
"path": "/www/server/nginx",

@ -16,6 +16,12 @@
"type": "语言解释器",
"pid": "1",
"versions": [
{
"status": false,
"version": "5.2",
"no": "",
"task": "1"
},
{
"status": false,
"version": "5.3",

@ -14,5 +14,5 @@
"date":"2017-11-24",
"default":true,
"display":1,
"pid": "3"
"pid": "5"
}

@ -69,23 +69,28 @@ def list():
return jsonify(ret)
@plugins.route("/install", methods=['POST'])
@plugins.route('/install', methods=['POST'])
def install():
rundir = public.getRunDir()
name = request.form['name']
if name.strip() == '':
return ''
name = request.form.get('name', '')
infoJson = __plugin_name + "/" + name + "/info.json"
install = __plugin_name + "/" + name + "/install.sh"
if name.strip() == '':
return public.retJson(-1, "123", ())
pluginInfo = json.loads(public.readFile(infoJson))
infoJsonPos = __plugin_name + '/' + name + '/' + 'info.json'
print pluginInfo
if not os.path.exists(infoJsonPos):
return public.retJson(-1, "1233", ())
pluginInfo = json.loads(public.readFile(infoJsonPos))
print install
os.system('/bin/bash ' + install + ' install')
sh = __plugin_name + '/' + name + '/' + pluginInfo['shell']
os.system('/bin/bash ' + sh + ' install')
print request.args
return ''
@plugins.route('/uninstall', methods=['POST'])
def uninstall():
pass

Loading…
Cancel
Save