mirror of https://github.com/midoks/mdserver-web
parent
75ece2a5de
commit
f1ef6f6f41
@ -1,20 +0,0 @@ |
||||
# coding:utf-8 |
||||
|
||||
import sys |
||||
sys.path.append("/class/core") |
||||
import public |
||||
|
||||
from flask import Blueprint, render_template |
||||
|
||||
crontab = Blueprint('crontab', __name__, template_folder='templates') |
||||
|
||||
|
||||
@crontab.route("/") |
||||
def index(): |
||||
return render_template('default/crontab.html') |
||||
|
||||
|
||||
@crontab.route("/list", methods=['GET', 'POST']) |
||||
def list(): |
||||
data = [] |
||||
return public.getJson({}) |
@ -1,95 +0,0 @@ |
||||
# coding:utf-8 |
||||
|
||||
import os |
||||
import sys |
||||
|
||||
from flask import Flask |
||||
from flask import Blueprint, render_template |
||||
from flask import jsonify |
||||
from flask import request |
||||
from flask import send_file, send_from_directory |
||||
from flask import make_response |
||||
|
||||
|
||||
sys.path.append("class/core") |
||||
import public |
||||
import file_api |
||||
|
||||
files = Blueprint('files', __name__, template_folder='templates') |
||||
|
||||
|
||||
@files.route("/") |
||||
def index(): |
||||
return render_template('default/files.html') |
||||
|
||||
|
||||
@files.route('/get_body', methods=['POST']) |
||||
def getBody(): |
||||
path = request.form.get('path', '').encode('utf-8') |
||||
return file_api.file_api().getBody(path) |
||||
|
||||
|
||||
@files.route('/save_body', methods=['POST']) |
||||
def saveBody(): |
||||
path = request.form.get('path', '').encode('utf-8') |
||||
data = request.form.get('data', '').encode('utf-8') |
||||
encoding = request.form.get('encoding', '').encode('utf-8') |
||||
return file_api.file_api().saveBody(path, data, encoding) |
||||
|
||||
|
||||
@files.route('/download', methods=['GET']) |
||||
def download(): |
||||
filename = request.args.get('filename', '').encode('utf-8') |
||||
if not os.path.exists(filename): |
||||
return '' |
||||
|
||||
response = make_response(send_from_directory( |
||||
os.path.dirname(filename), os.path.basename(filename), as_attachment=True)) |
||||
return response |
||||
|
||||
|
||||
@files.route('/zip', methods=['POST']) |
||||
def zip(): |
||||
sfile = request.form.get('sfile', '').encode('utf-8') |
||||
dfile = request.form.get('dfile', '').encode('utf-8') |
||||
stype = request.form.get('type', '').encode('utf-8') |
||||
path = request.form.get('path', '').encode('utf-8') |
||||
return file_api.file_api().zip(sfile, dfile, stype, path) |
||||
|
||||
|
||||
@files.route('/delete', methods=['POST']) |
||||
def delete(): |
||||
path = request.form.get('path', '').encode('utf-8') |
||||
return file_api.file_api().delete(path) |
||||
|
||||
|
||||
@files.route('/file_access', methods=['POST']) |
||||
def fileAccess(): |
||||
filename = request.form.get('filename', '').encode('utf-8') |
||||
data = file_api.file_api().getAccess(filename) |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@files.route('/get_dir_size', methods=['POST']) |
||||
def getDirSize(): |
||||
path = request.form.get('path', '').encode('utf-8') |
||||
if public.getOs() == 'darwin': |
||||
tmp = public.execShell('du -sh ' + path) |
||||
else: |
||||
tmp = public.execShell('du -sbh ' + path) |
||||
# print tmp |
||||
return public.returnJson(True, tmp[0].split()[0]) |
||||
|
||||
|
||||
@files.route('/get_dir', methods=['POST']) |
||||
def getDir(): |
||||
path = request.form.get('path', '').encode('utf-8') |
||||
if not os.path.exists(path): |
||||
path = public.getRootDir() + "/wwwroot" |
||||
|
||||
search = request.args.get('search', '').strip().lower() |
||||
page = request.args.get('p', '1').strip().lower() |
||||
row = request.args.get('showRow', '10') |
||||
|
||||
# print path, int(page), int(row), search |
||||
return file_api.file_api().getDir(path, int(page), int(row), search) |
@ -1,61 +0,0 @@ |
||||
# coding:utf-8 |
||||
|
||||
import sys |
||||
import os |
||||
import re |
||||
|
||||
from flask import Flask |
||||
from flask import Blueprint, render_template |
||||
from flask import request |
||||
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core/") |
||||
import db |
||||
import public |
||||
import firewall_api |
||||
|
||||
firewall = Blueprint('firewall', __name__, template_folder='templates') |
||||
|
||||
|
||||
@firewall.route('/') |
||||
def index(): |
||||
return render_template('default/firewall.html') |
||||
|
||||
|
||||
@firewall.route('/get_www_path', methods=['POST']) |
||||
def getWwwPath(): |
||||
path = public.getLogsDir() |
||||
return public.getJson({'path': path}) |
||||
|
||||
|
||||
@firewall.route("/get_list", methods=['POST']) |
||||
def getList(): |
||||
p = request.form.get('p', '1').strip() |
||||
limit = request.form.get('limit', '10').strip() |
||||
return firewall_api.firewall_api().getList(int(p), int(limit)) |
||||
|
||||
|
||||
@firewall.route("/get_log_list", methods=['POST']) |
||||
def getLogList(): |
||||
p = request.form.get('p', '1').strip() |
||||
limit = request.form.get('limit', '10').strip() |
||||
search = request.form.get('search', '').strip() |
||||
return firewall_api.firewall_api().getLogList(int(p), int(limit), search) |
||||
|
||||
|
||||
@firewall.route('get_ssh_info', methods=['POST']) |
||||
def getSshInfo(): |
||||
file = '/etc/ssh/sshd_config' |
||||
conf = public.readFile(file) |
||||
rep = "#*Port\s+([0-9]+)\s*\n" |
||||
port = re.search(rep, conf).groups(0)[0] |
||||
|
||||
data = {} |
||||
data['port'] = port |
||||
data['status'] = True |
||||
data['ping'] = True |
||||
if public.isAppleSystem(): |
||||
data['firewall_status'] = False |
||||
else: |
||||
data['firewall_status'] = True |
||||
return public.getJson(data) |
@ -1,190 +0,0 @@ |
||||
# coding:utf-8 |
||||
|
||||
import time |
||||
import sys |
||||
import os |
||||
import json |
||||
import psutil |
||||
|
||||
from flask import Blueprint, render_template |
||||
from flask import jsonify |
||||
from flask import request |
||||
|
||||
sys.path.append("class/core") |
||||
import public |
||||
import plugin_api |
||||
|
||||
|
||||
plugins = Blueprint('plugins', __name__, template_folder='templates') |
||||
__plugin_name = "plugins" |
||||
__row_num = 3 |
||||
|
||||
|
||||
@plugins.route('/file', methods=['GET']) |
||||
def file(): |
||||
name = request.args.get('name', '') |
||||
if name.strip() == '': |
||||
return '' |
||||
|
||||
f = request.args.get('f', '') |
||||
if f.strip() == '': |
||||
return '' |
||||
|
||||
file = __plugin_name + '/' + name + '/' + f |
||||
if not os.path.exists(file): |
||||
return '' |
||||
|
||||
c = public.readFile(file) |
||||
return c |
||||
|
||||
|
||||
@plugins.route('/list', methods=['GET']) |
||||
def list(): |
||||
sType = request.args.get('type', '0') |
||||
sPage = request.args.get('p', '1') |
||||
data = plugin_api.plugin_api().getPluginList(sType, int(sPage)) |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@plugins.route('/index_list', methods=['GET']) |
||||
def indexList(): |
||||
data = plugin_api.plugin_api().getIndexList() |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@plugins.route('/index_sort', methods=['POST']) |
||||
def indexSort(): |
||||
sort = request.form.get('ssort', '') |
||||
if sort.strip() == '': |
||||
return public.returnJson(False, '排序数据不能为空!') |
||||
data = plugin_api.plugin_api().setIndexSort(sort) |
||||
if data: |
||||
return public.returnJson(True, '成功!') |
||||
return public.returnJson(False, '失败!') |
||||
|
||||
|
||||
@plugins.route('/install', methods=['POST']) |
||||
def install(): |
||||
|
||||
rundir = public.getRunDir() |
||||
name = request.form.get('name', '') |
||||
version = request.form.get('version', '') |
||||
|
||||
mmsg = '安装' |
||||
if hasattr(request.form, 'upgrade'): |
||||
mtype = 'update' |
||||
mmsg = 'upgrade' |
||||
|
||||
if name.strip() == '': |
||||
return public.returnJson(False, '缺少插件名称!', ()) |
||||
|
||||
if version.strip() == '': |
||||
return public.returnJson(False, '缺少版本信息!', ()) |
||||
|
||||
infoJsonPos = __plugin_name + '/' + name + '/' + 'info.json' |
||||
|
||||
if not os.path.exists(infoJsonPos): |
||||
return public.retJson(False, '配置文件不存在!', ()) |
||||
|
||||
pluginInfo = json.loads(public.readFile(infoJsonPos)) |
||||
|
||||
execstr = "cd " + os.getcwd() + "/plugins/" + \ |
||||
name + " && /bin/bash " + pluginInfo["shell"] \ |
||||
+ " install " + version |
||||
|
||||
taskAdd = (None, mmsg + '[' + name + '-' + version + ']', |
||||
'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr) |
||||
|
||||
public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd) |
||||
return public.returnJson(True, '已将安装任务添加到队列!') |
||||
|
||||
|
||||
@plugins.route('/uninstall', methods=['POST']) |
||||
def uninstall(): |
||||
rundir = public.getRunDir() |
||||
name = request.form.get('name', '') |
||||
version = request.form.get('version', '') |
||||
if name.strip() == '': |
||||
return public.returnJson(False, "缺少插件名称!", ()) |
||||
|
||||
if version.strip() == '': |
||||
return public.returnJson(False, "缺少版本信息!", ()) |
||||
|
||||
infoJsonPos = __plugin_name + '/' + name + '/' + 'info.json' |
||||
|
||||
if not os.path.exists(infoJsonPos): |
||||
return public.retJson(False, "配置文件不存在!", ()) |
||||
|
||||
pluginInfo = json.loads(public.readFile(infoJsonPos)) |
||||
|
||||
execstr = "cd " + os.getcwd() + "/plugins/" + \ |
||||
name + " && /bin/bash " + pluginInfo["shell"] \ |
||||
+ " uninstall " + version |
||||
|
||||
taskAdd = (None, '卸载[' + name + '-' + version + ']', |
||||
'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr) |
||||
|
||||
public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd) |
||||
return public.returnJson(True, '已将卸载任务添加到队列!') |
||||
|
||||
|
||||
@plugins.route('/find', methods=['POST']) |
||||
def installed(): |
||||
|
||||
rundir = public.getRunDir() |
||||
name = request.form.get('name', '') |
||||
|
||||
if name.strip() == '': |
||||
return public.retJson(-1, "缺少插件名称!", ()) |
||||
|
||||
infoJsonPos = __plugin_name + '/' + name + '/' + 'info.json' |
||||
if not os.path.exists(infoJsonPos): |
||||
return public.returnJson(-1, "配置文件不存在!", ()) |
||||
|
||||
pluginInfo = json.loads(public.readFile(infoJsonPos)) |
||||
|
||||
sh = __plugin_name + '/' + name + '/' + pluginInfo['shell'] |
||||
os.system('/bin/bash ' + sh + ' install') |
||||
print request.args |
||||
return '' |
||||
|
||||
|
||||
@plugins.route('/check_installed', methods=['POST']) |
||||
def checkInstalled(): |
||||
checks = ['nginx', 'apache', 'php', 'mysql'] |
||||
for name in checks: |
||||
filename = public.getRootDir() + "/server/" + name |
||||
if os.path.exists(filename): |
||||
return "True" |
||||
return "False" |
||||
|
||||
|
||||
@plugins.route('/set_index', methods=['POST']) |
||||
def setIndex(): |
||||
name = request.form.get('name', '') |
||||
status = request.form.get('status', '0') |
||||
version = request.form.get('version', '') |
||||
if status == '1': |
||||
return plugin_api.plugin_api().addIndex(name, version) |
||||
return plugin_api.plugin_api().removeIndex(name, version) |
||||
|
||||
|
||||
@plugins.route('/setting', methods=['GET']) |
||||
def setting(): |
||||
name = request.args.get('name', '') |
||||
html = __plugin_name + '/' + name + '/index.html' |
||||
return public.readFile(html) |
||||
|
||||
|
||||
@plugins.route('/run', methods=['POST', 'GET']) |
||||
def run(): |
||||
name = request.form.get('name', '') |
||||
func = request.form.get('func', '') |
||||
version = request.form.get('version', '') |
||||
args = request.form.get('args', '') |
||||
script = request.form.get('script', 'index') |
||||
|
||||
data = plugin_api.plugin_api().run(name, func, version, args, script) |
||||
if data[1] == '': |
||||
return public.returnJson(True, "OK", data[0].strip()) |
||||
return public.returnJson(False, data[1].strip()) |
@ -1,154 +0,0 @@ |
||||
# coding:utf-8 |
||||
|
||||
import time |
||||
import sys |
||||
import os |
||||
import json |
||||
|
||||
from flask import Flask |
||||
from flask import Blueprint, render_template |
||||
from flask import request |
||||
|
||||
site = Blueprint('site', __name__, template_folder='templates') |
||||
|
||||
sys.path.append("class/core") |
||||
import public |
||||
import site_api |
||||
|
||||
|
||||
@site.route('/') |
||||
def index(): |
||||
return render_template('default/site.html') |
||||
|
||||
|
||||
@site.route('/list', methods=['POST']) |
||||
def list(): |
||||
return site_api.site_api().list() |
||||
|
||||
|
||||
@site.route('get_php_version', methods=['POST']) |
||||
def getPhpVersion(): |
||||
return site_api.site_api().getPhpVersion() |
||||
|
||||
|
||||
@site.route('get_domain', methods=['POST']) |
||||
def getDomain(): |
||||
pid = request.form.get('pid', '').encode('utf-8') |
||||
return site_api.site_api().getDomain(pid) |
||||
|
||||
|
||||
@site.route('get_index', methods=['POST']) |
||||
def getIndex(): |
||||
sid = request.form.get('id', '').encode('utf-8') |
||||
data = {} |
||||
index = site_api.site_api().getIndex(sid) |
||||
data['index'] = index |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@site.route('set_index', methods=['POST']) |
||||
def setIndex(): |
||||
sid = request.form.get('id', '').encode('utf-8') |
||||
index = request.form.get('index', '').encode('utf-8') |
||||
return site_api.site_api().setIndex(sid, index) |
||||
|
||||
|
||||
@site.route('get_limit_net', methods=['POST']) |
||||
def getLimitNet(): |
||||
sid = request.form.get('id', '').encode('utf-8') |
||||
return site_api.site_api().getLimitNet(sid) |
||||
|
||||
|
||||
@site.route('save_limit_net', methods=['POST']) |
||||
def saveLimitNet(): |
||||
sid = request.form.get('id', '').encode('utf-8') |
||||
perserver = request.form.get('perserver', '').encode('utf-8') |
||||
perip = request.form.get('perip', '').encode('utf-8') |
||||
limit_rate = request.form.get('limit_rate', '').encode('utf-8') |
||||
return site_api.site_api().saveLimitNet(sid, perserver, perip, limit_rate) |
||||
|
||||
|
||||
@site.route('close_limit_net', methods=['POST']) |
||||
def closeLimitNet(): |
||||
sid = request.form.get('id', '').encode('utf-8') |
||||
return site_api.site_api().closeLimitNet(sid) |
||||
|
||||
|
||||
@site.route('get_security', methods=['POST']) |
||||
def getSecurity(): |
||||
sid = request.form.get('id', '').encode('utf-8') |
||||
name = request.form.get('name', '').encode('utf-8') |
||||
return site_api.site_api().getSecurity(sid, name) |
||||
|
||||
|
||||
@site.route('set_security', methods=['POST']) |
||||
def setSecurity(): |
||||
fix = request.form.get('fix', '').encode('utf-8') |
||||
domains = request.form.get('domains', '').encode('utf-8') |
||||
status = request.form.get('status', '').encode('utf-8') |
||||
name = request.form.get('name', '').encode('utf-8') |
||||
sid = request.form.get('id', '').encode('utf-8') |
||||
return site_api.site_api().setSecurity(sid, name, fix, domains, status) |
||||
|
||||
|
||||
@site.route('get_logs', methods=['POST']) |
||||
def getLogs(): |
||||
siteName = request.form.get('siteName', '').encode('utf-8') |
||||
return site_api.site_api().getLogs(siteName) |
||||
|
||||
|
||||
@site.route('get_site_php_version', methods=['POST']) |
||||
def getSitePhpVersion(): |
||||
siteName = request.form.get('siteName', '').encode('utf-8') |
||||
return site_api.site_api().getSitePhpVersion(siteName) |
||||
|
||||
|
||||
@site.route('get_host_conf', methods=['POST']) |
||||
def getHostConf(): |
||||
siteName = request.form.get('siteName', '').encode('utf-8') |
||||
host = site_api.site_api().getHostConf(siteName) |
||||
return public.getJson({'host': host}) |
||||
|
||||
|
||||
@site.route('get_rewrite_conf', methods=['POST']) |
||||
def getRewriteConf(): |
||||
siteName = request.form.get('siteName', '').encode('utf-8') |
||||
rewrite = site_api.site_api().getRewriteConf(siteName) |
||||
return public.getJson({'rewrite': rewrite}) |
||||
|
||||
|
||||
@site.route('get_rewrite_list', methods=['POST']) |
||||
def getRewriteList(): |
||||
rlist = site_api.site_api().getRewriteList() |
||||
return public.getJson(rlist) |
||||
|
||||
|
||||
@site.route('get_root_dir', methods=['POST']) |
||||
def getRootDir(): |
||||
data = {} |
||||
data['dir'] = public.getWwwDir() |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@site.route('set_end_date', methods=['POST']) |
||||
def setEndDate(): |
||||
sid = request.form.get('id', '').encode('utf-8') |
||||
edate = request.form.get('edate', '').encode('utf-8') |
||||
return site_api.site_api().setEndDate(sid, edate) |
||||
|
||||
|
||||
@site.route('add', methods=['POST']) |
||||
def add(): |
||||
webname = request.form.get('webinfo', '').encode('utf-8') |
||||
ps = request.form.get('ps', '').encode('utf-8') |
||||
path = request.form.get('path', '').encode('utf-8') |
||||
version = request.form.get('version', '').encode('utf-8') |
||||
port = request.form.get('port', '').encode('utf-8') |
||||
return site_api.site_api().add(webname, port, ps, path, version) |
||||
|
||||
|
||||
@site.route('delete', methods=['POST']) |
||||
def delete(): |
||||
sid = request.form.get('id', '').encode('utf-8') |
||||
webname = request.form.get('webname', '').encode('utf-8') |
||||
return site_api.site_api().delete(sid, webname) |
@ -1,10 +0,0 @@ |
||||
# coding:utf-8 |
||||
|
||||
from flask import Blueprint, render_template |
||||
|
||||
soft = Blueprint('soft', __name__, template_folder='templates') |
||||
|
||||
|
||||
@soft.route("/") |
||||
def index (): |
||||
return render_template('default/soft.html') |
@ -1,83 +0,0 @@ |
||||
# coding:utf-8 |
||||
|
||||
import time |
||||
import psutil |
||||
import os |
||||
import sys |
||||
|
||||
from flask import Flask, session |
||||
from flask import Blueprint, render_template |
||||
from flask import jsonify |
||||
from flask import request |
||||
|
||||
sys.path.append("class/core") |
||||
import public |
||||
import system_api |
||||
|
||||
system = Blueprint('system', __name__, template_folder='templates') |
||||
|
||||
|
||||
@system.route("/network") |
||||
def network(): |
||||
data = system_api.system_api().getNetWork() |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@system.route("/update_server") |
||||
def updateServer(): |
||||
stype = request.args.get('type', 'check') |
||||
version = request.args.get('version', '') |
||||
data = system_api.system_api().updateServer(stype, version) |
||||
return data |
||||
|
||||
|
||||
@system.route("/system_total") |
||||
def systemTotal(): |
||||
data = system_api.system_api().getSystemTotal() |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@system.route("/disk_info") |
||||
def diskInfo(): |
||||
diskInfo = system_api.system_api().getDiskInfo() |
||||
return public.getJson(diskInfo) |
||||
|
||||
|
||||
@system.route('/set_control', methods=['POST']) |
||||
def setControl(): |
||||
stype = request.form.get('type', '') |
||||
day = request.form.get('day', '') |
||||
data = system_api.system_api().setControl(stype, day) |
||||
return data |
||||
|
||||
|
||||
@system.route('/get_load_average', methods=['GET']) |
||||
def getLoadAverage(): |
||||
start = request.args.get('start', '') |
||||
end = request.args.get('end', '') |
||||
data = system_api.system_api().getLoadAverageData(start, end) |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@system.route('/get_cpu_io', methods=['GET']) |
||||
def getCpuIo(): |
||||
start = request.args.get('start', '') |
||||
end = request.args.get('end', '') |
||||
data = system_api.system_api().getCpuIoData(start, end) |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@system.route('/get_disk_io', methods=['GET']) |
||||
def getDiskIo(): |
||||
start = request.args.get('start', '') |
||||
end = request.args.get('end', '') |
||||
data = system_api.system_api().getDiskIoData(start, end) |
||||
return public.getJson(data) |
||||
|
||||
|
||||
@system.route('/get_network_io', methods=['GET']) |
||||
def getNetworkIo(): |
||||
start = request.args.get('start', '') |
||||
end = request.args.get('end', '') |
||||
data = system_api.system_api().getNetWorkIoData(start, end) |
||||
return public.getJson(data) |
Loading…
Reference in new issue