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

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

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

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

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

@ -69,23 +69,28 @@ def list():
return jsonify(ret) return jsonify(ret)
@plugins.route("/install", methods=['POST']) @plugins.route('/install', methods=['POST'])
def install(): def install():
rundir = public.getRunDir() rundir = public.getRunDir()
name = request.form['name'] name = request.form.get('name', '')
if name.strip() == '':
return ''
infoJson = __plugin_name + "/" + name + "/info.json" if name.strip() == '':
install = __plugin_name + "/" + name + "/install.sh" 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 sh = __plugin_name + '/' + name + '/' + pluginInfo['shell']
os.system('/bin/bash ' + install + ' install') os.system('/bin/bash ' + sh + ' install')
print request.args print request.args
return '' return ''
@plugins.route('/uninstall', methods=['POST'])
def uninstall():
pass

Loading…
Cancel
Save