diff --git a/class/core/public.py b/class/core/public.py index 620b901f9..47c5d0b36 100755 --- a/class/core/public.py +++ b/class/core/public.py @@ -18,13 +18,11 @@ from random import Random def getRunDir(): - # 运行目录 return os.getcwd() -def getBinDir(): - # 安装软件 - pass +def getRootDir(): + return os.path.dirname(os.path.dirname(getRunDir())) def M(table): diff --git a/route/plugins.py b/route/plugins.py index 13d11a1dc..0708a71c1 100644 --- a/route/plugins.py +++ b/route/plugins.py @@ -10,7 +10,7 @@ import sys import os import json -sys.path.append("class/") +sys.path.append("class/core") import public @@ -130,7 +130,7 @@ def installed(): infoJsonPos = __plugin_name + '/' + name + '/' + 'info.json' if not os.path.exists(infoJsonPos): - return public.retJson(-1, "配置数据(info.json)不存在!", ()) + return public.returnJson(-1, "配置数据(info.json)不存在!", ()) pluginInfo = json.loads(public.readFile(infoJsonPos)) @@ -139,26 +139,12 @@ def installed(): print request.args return '' -# 取分页 - - -def get_page(data, args): - # 包含分页类 - import page - # 实例化分页类 - page = page.Page() - info = {} - info['count'] = len(data) - info['row'] = __row_num - info['p'] = 1 - if hasattr(args, 'p'): - info['p'] = int(get['p']) - info['uri'] = {} - info['return_js'] = '' - if hasattr(args, 'tojs'): - info['return_js'] = args.tojs - - # 获取分页数据 - result = {} - result['page'] = page.GetPage(info) - return result + +@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" diff --git a/route/system.py b/route/system.py index a91afb711..66ad07605 100644 --- a/route/system.py +++ b/route/system.py @@ -145,8 +145,13 @@ def diskinfo(): return jsonify(diskInfo) -@system.route("/systemtotal") -def systemtotal(): +@system.route("/update_panel") +def updatePanel(): + return public.returnJson(False, "12") + + +@system.route("/system_total") +def systemTotal(): # 取系统统计信息 data = GetMemInfo() cpu = GetCpuInfo(1) diff --git a/static/js/index.js b/static/js/index.js index 824c7c6d8..95da9256c 100755 --- a/static/js/index.js +++ b/static/js/index.js @@ -1,5 +1,5 @@ //检测是否安装环境 -$.post("/ajax?action=CheckInstalled", function(rdata) { +$.post("/plugins/check_installed", function(rdata) { if (rdata == false) { RecInstall(); } @@ -180,7 +180,7 @@ function ClearSystem() { } function getInfo() { - $.get("/system?action=GetSystemTotal", function(info) { + $.get("/system/system_total", function(info) { setCookie("memRealUsed", parseInt((info.memRealUsed))); $("#memory").html(parseInt((info.memRealUsed)) + '/' + info.memTotal + ' (MB)'); setCookie("mem-before", $("#memory").text()); @@ -205,7 +205,7 @@ function getInfo() { $("#messageError").append('
' + lan.index.user_warning + ' [不可忽略] [立即修改]
') } setImg(); - }); + },'json'); } @@ -450,25 +450,25 @@ function setImg() { setImg(); //检查更新 -setTimeout(function() { - $.get('/ajax?action=UpdatePanel', function(rdata) { - if (rdata.status == false) return; - if (rdata.version != undefined) { - $("#toUpdate").html('' + lan.index.update_go + ''); - return; - } - $.get('/system?action=ReWeb', function() {}); - layer.msg(rdata.msg, { icon: 1 }); - setTimeout(function() { - window.location.reload(); - }, 3000); - }).error(function() { - $.get('/system?action=ReWeb', function() {}); - setTimeout(function() { - window.location.reload(); - }, 3000); - }); -}, 3000); +// setTimeout(function() { +// $.get('/system/update_panel', function(rdata) { +// if (rdata.status == false) return; +// if (rdata.version != undefined) { +// $("#toUpdate").html('' + lan.index.update_go + ''); +// return; +// } +// $.get('/system?action=ReWeb', function() {}); +// layer.msg(rdata.msg, { icon: 1 }); +// setTimeout(function() { +// window.location.reload(); +// }, 3000); +// }).error(function() { +// $.get('/system?action=ReWeb', function() {}); +// setTimeout(function() { +// window.location.reload(); +// }, 3000); +// },'json'); +// }, 3000); //检查更新 @@ -603,20 +603,20 @@ function WSafeRestart() { $.post('/system?action=RestartServer', '', function(rdata) { $(".SafeRestartCode").html("" + lan.index.reboot_msg_1 + "
" + lan.index.reboot_msg_2 + "
" + lan.index.reboot_msg_3 + "
" + lan.index.reboot_msg_4 + "...
"); var sEver = setInterval(function() { - $.get("/system?action=GetSystemTotal", function(info) { + $.get("/system/system_total", function(info) { clearInterval(sEver); $(".SafeRestartCode").html("" + lan.index.reboot_msg_1 + "
" + lan.index.reboot_msg_2 + "
" + lan.index.reboot_msg_3 + "
" + lan.index.reboot_msg_4 + "
" + lan.index.reboot_msg_5 + "
"); setTimeout(function() { layer.closeAll(); }, 3000); - }).error(function() { + },'json').error(function() { }); }, 3000); }).error(function() { $(".SafeRestartCode").html("" + lan.index.reboot_msg_1 + "
" + lan.index.reboot_msg_2 + "
" + lan.index.reboot_msg_3 + "
" + lan.index.reboot_msg_4 + "...
"); var sEver = setInterval(function() { - $.get("/system?action=GetSystemTotal", function(info) { + $.get("/system/system_total", function(info) { clearInterval(sEver); $(".SafeRestartCode").html("" + lan.index.reboot_msg_1 + "
" + lan.index.reboot_msg_2 + "
" + lan.index.reboot_msg_3 + "
" + lan.index.reboot_msg_4 + "
" + lan.index.reboot_msg_5 + "
"); setTimeout(function() { @@ -624,7 +624,7 @@ function WSafeRestart() { window.location.reload(); }, 3000); - }).error(function() { + },'json').error(function() { }); }, 3000); @@ -635,19 +635,19 @@ function WSafeRestart() { } function reWeb() { - layer.confirm(lan.index.panel_reboot_msg, { title: lan.index.panel_reboot_title, closeBtn: 2, icon: 3 }, function() { - var loadT = layer.msg(lan.index.panel_reboot_to, { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.get('/system?action=ReWeb', function(rdata) { - layer.close(loadT); - layer.msg(rdata.msg, { icon: 5 }); - }).error(function() { - layer.close(loadT); - layer.msg(lan.index.panel_reboot_ok, { icon: 1 }); - setTimeout(function() { - window.location.reload(); - }, 3000) - }); - }); + // layer.confirm(lan.index.panel_reboot_msg, { title: lan.index.panel_reboot_title, closeBtn: 2, icon: 3 }, function() { + // var loadT = layer.msg(lan.index.panel_reboot_to, { icon: 16, time: 0, shade: [0.3, '#000'] }); + // $.get('/system?action=ReWeb', function(rdata) { + // layer.close(loadT); + // layer.msg(rdata.msg, { icon: 5 }); + // }).error(function() { + // layer.close(loadT); + // layer.msg(lan.index.panel_reboot_ok, { icon: 1 }); + // setTimeout(function() { + // window.location.reload(); + // }, 3000) + // }); + // }); } diff --git a/templates/default/index.html b/templates/default/index.html index e6f14852e..fe1003392 100755 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -6,7 +6,7 @@ 首页/服务器状态 - 免费版 0.0.1 + 版本信息 0.0.1 检查更新 @@ -146,13 +146,13 @@ setCookie('serverType', '$web.ctx.session.webserver'); var serverType = getCookie('serverType'); - - - - - - - + + + + + + + {% block content %}{% endblock %} - +