diff --git a/class/core/config.py b/class/core/config.py deleted file mode 100644 index 809e0d660..000000000 --- a/class/core/config.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding:utf-8 - -import sys -import io -import os -import time -import shutil - -reload(sys) -sys.setdefaultencoding('utf8') - -from flask import Flask, session -from datetime import timedelta - -sys.path.append(os.getcwd() + "/class/core") -import db -import public - - -class middleWare: - - def __init__(self, wsgi_app): - self.wsgi_app = wsgi_app - - def __call__(self, *args, **kwargs): - return self.wsgi_app(*args, **kwargs) - - -class config: - __version = '0.0.1' - __app = None - __modules = None - - def __init__(self): - pass - - def makeApp(self, name): - app = Flask(name) - self.__app = app - - app.config.version = self.__version - app.config['SECRET_KEY'] = os.urandom(24) - app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7) - - self.initDB() - self.initInitD() - self.initRoute() - # self.startDebug() - app.wsgi_app = middleWare(app.wsgi_app) - return app - - def startDebug(self): - self.__app.debug = True - self.__app.config.version = self.__version + str(time.time()) - - def initDB(self): - try: - sql = db.Sql().dbfile('default') - csql = public.readFile('data/sql/default.sql') - csql_list = csql.split(';') - for index in range(len(csql_list)): - sql.execute(csql_list[index], ()) - except Exception, ex: - print str(ex) - - def initUser(self): - pass - - def initInitD(self): - script = public.getRunDir() + '/scripts/init.d/mw.tpl' - script_bin = public.getRunDir() + '/scripts/init.d/mw' - if os.path.exists(script_bin): - return - - content = public.readFile(script) - content = content.replace("{$SERVER_PATH}", public.getRunDir()) - - public.writeFile(script_bin, content) - public.execShell('chmod +x ' + script_bin) - - if public.getOs() != 'darwin': - initd_bin = '/etc/init.d/mw' - if not os.path.exists(initd_bin): - shutil.copyfile(script_bin, initd_bin) - public.execShell('chmod +x ' + initd_bin) - - def getVersion(self): - return self.__version - - def getApp(self): - return self.__app - - def initRoute(self): - import route - DEFAULT_MODULES = ( - (route.dashboard, "/"), - (route.site, "/site"), - (route.files, "/files"), - (route.soft, "/soft"), - (route.config, "/config"), - (route.plugins, "/plugins"), - (route.task, "/task"), - (route.system, "/system"), - (route.database, "/database"), - (route.crontab, "/crontab"), - (route.firewall, "/firewall"), - (route.control, "/control") - ) - self.modules = DEFAULT_MODULES - self.settingModules(self.__app, DEFAULT_MODULES) - - def settingModules(self, app, modules): - for module, url_prefix in modules: - app.register_blueprint(module, url_prefix=url_prefix) diff --git a/class/core/config_api.py b/class/core/config_api.py index 7223beb3e..fdd0a7aef 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -9,6 +9,9 @@ import re import json import pwd +from flask import session +from flask import request + class config_api: @@ -16,14 +19,50 @@ class config_api: pass ##### ----- start ----- ### + def syncDateApi(self): + if public.isAppleSystem(): + return public.returnJson(True, '开发系统不必同步时间!') + + data = public.execShell('ntpdate -s time.nist.gov') + if data[0] == '': + return public.returnJson(True, '同步成功!') + return public.returnJson(False, '同步失败:' + data[0]) + + def setPasswordApi(self): + password1 = request.form.get('password1', '') + password2 = request.form.get('password2', '') + if password1 != password2: + return public.returnJson(False, '两次输入的密码不一致,请重新输入!') + if len(password1) < 5: + return public.returnJson(False, '用户密码不能小于5位!') + public.M('users').where("username=?", (session['username'],)).setField( + 'password', public.md5(password1.strip())) + return public.returnJson(True, '密码修改成功!') + + def setNameApi(self): + name1 = request.form.get('name1', '') + name2 = request.form.get('name2', '') + if name1 != name2: + return public.returnJson(False, '两次输入的用户名不一致,请重新输入!') + if len(name1) < 3: + return public.returnJson(False, '用户名长度不能少于3位') + + public.M('users').where("username=?", (session['username'],)).setField( + 'username', name1.strip()) + + session['username'] = name1 + return public.returnJson(True, '用户修改成功!') + + ##### ----- end ----- ### + def get(self): data = {} data['site_path'] = public.getWwwDir() data['backup_path'] = public.getBackupDir() - data['systemdate'] = public.execShell( - 'date +"%Y-%m-%d %H:%M:%S %Z %z"')[0].strip() + sformat = 'date +"%Y-%m-%d %H:%M:%S %Z %z"' + data['systemdate'] = public.execShell(sformat)[0].strip() if os.path.exists('data/port.pl'): data['port'] = public.readFile('data/port.pl').strip() @@ -35,5 +74,7 @@ class config_api: else: data['ip'] = '127.0.0.1' + data['username'] = public.M('users').where( + "id=?", (1,)).getField('username') + return data - ##### ----- end ----- ### diff --git a/plugins/gae/info.json b/plugins/gae/info.json index 5686e463b..c06ee2c23 100755 --- a/plugins/gae/info.json +++ b/plugins/gae/info.json @@ -2,7 +2,7 @@ "title":"GAE", "tip":"soft", "name":"gae", - "ps":"GAE 英文全称为Google App Engine。它是Google管理的数据中心中用于WEB应用程序的开发和托管的平台", + "ps":"GAE(Google App Engine)。它是Google管理的数据中心中用于WEB应用程序的开发和托管的平台", "versions": "0.1", "shell":"install.sh", "checks":"server/gae", diff --git a/route/__init__.py b/route/__init__.py index cd880b575..3614e604b 100755 --- a/route/__init__.py +++ b/route/__init__.py @@ -7,6 +7,9 @@ import time import shutil import uuid +reload(sys) +sys.setdefaultencoding('utf8') + from datetime import timedelta from flask import Flask @@ -28,8 +31,8 @@ import public app = Flask(__name__, template_folder='templates/default') app.config.version = '0.0.1' # app.config['SECRET_KEY'] = os.urandom(24) -app.config['SECRET_KEY'] = uuid.UUID(int=uuid.getnode()).hex[-12:] # app.secret_key = uuid.UUID(int=uuid.getnode()).hex[-12:] +app.config['SECRET_KEY'] = uuid.UUID(int=uuid.getnode()).hex[-12:] app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7) try: from flask_sqlalchemy import SQLAlchemy diff --git a/route/static/app/config.js b/route/static/app/config.js index b673fac7c..fba266c2b 100755 --- a/route/static/app/config.js +++ b/route/static/app/config.js @@ -1,8 +1,9 @@ $(".set-submit").click(function(){ - var data = $("#set-Config").serialize(); - layer.msg(lan.config.config_save,{icon:16,time:0,shade: [0.3, '#000']}); + var data = $("#set_config").serialize(); + console.log(data); + layer.msg('正在保存配置...',{icon:16,time:0,shade: [0.3, '#000']}); $.post('/config?action=setPanel',data,function(rdata){ layer.closeAll(); layer.msg(rdata.msg,{icon:rdata.status?1:2}); @@ -15,31 +16,145 @@ $(".set-submit").click(function(){ }); //设置自动更新 -function SetPanelAutoUpload(){ +function setPanelAutoUpload(){ loadT = layer.msg(lan.public.config,{icon:16,time:0}); - $.post('/config?action=AutoUpdatePanel','',function(rdata){ + $.post('/config?action=AutoUpdatePanel', '', function(rdata){ layer.close(loadT); layer.msg(rdata.msg,{icon:rdata.status?1:2}); }); } - -function syncDate(){ - var loadT = layer.msg(lan.config.config_sync,{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/config?action=syncDate','',function(rdata){ - layer.close(loadT); - layer.msg(rdata.msg,{icon:1}); - setTimeout(function(){ - window.location.reload(); - },1500); +function setPassword(a) { + if(a == 1) { + p1 = $("#p1").val(); + p2 = $("#p2").val(); + if(p1 == "" || p1.length < 8) { + layer.msg('面板密码不能少于8位!', {icon: 2}); + return + } + + //准备弱口令匹配元素 + var checks = ['admin888','123123123','12345678','45678910','87654321','asdfghjkl','password','qwerqwer']; + pchecks = 'abcdefghijklmnopqrstuvwxyz1234567890'; + for(var i=0;i\ +
\ + 密码\ +
\ +
\ +
\ + 重复\ +
\ +
\ +
\ + 随机\ + \ + \ +
\ + " }); } -//PHP守护程序 -function Set502(){ - var loadT = layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/config?action=Set502','',function(rdata){ + +function randPwd(){ + var pwd = randomStrPwd(12); + $("#p1").val(pwd); + $("#p2").val(pwd); + layer.msg(lan.bt.pass_rep_ps,{time:2000}) +} + +function setUserName(a) { + if(a == 1) { + p1 = $("#p1").val(); + p2 = $("#p2").val(); + if(p1 == "" || p1.length < 3) { + layer.msg('用户名长度不能少于3位', {icon: 2}); + return; + } + if(p1 != p2) { + layer.msg('两次输入的用户名不一致', {icon: 2}); + return; + } + $.post("/config/set_name", "name1=" + encodeURIComponent(p1) + "&name2=" + encodeURIComponent(p2), function(b) { + if(b.status) { + layer.closeAll(); + layer.msg(b.msg, {icon: 1}); + $("input[name='username_']").val(p1) + } else { + layer.msg(b.msg, {icon: 2}); + } + },'json'); + return + } + layer.open({ + type: 1, + area: "290px", + title: '修改面板用户名', + closeBtn: 2, + shift: 5, + shadeClose: false, + content: "
\ +
用户名\ +
\ +
\ +
\ + 重复\ +
\ +
\ +
\ + \ + \ +
\ +
" + }) +} + + +function syncDate(){ + var loadT = layer.msg('正在同步时间...',{icon:16,time:0,shade: [0.3, '#000']}); + $.post('/config/sync_date','',function(rdata){ layer.close(loadT); layer.msg(rdata.msg,{icon:rdata.status?1:2}); - }); + setTimeout(function(){ + window.location.reload(); + },1500); + },'json'); } \ No newline at end of file diff --git a/route/static/app/control.js b/route/static/app/control.js index 9857cfcd6..2224ca2fa 100755 --- a/route/static/app/control.js +++ b/route/static/app/control.js @@ -119,13 +119,11 @@ function GetToday(){ return str; } - - //取监控状态 function getStatus(){ loadT = layer.msg(lan.public.read,{icon:16,time:0}) $.post('/system/set_control','type=-1',function(rdata){ - console.log(rdata); + // console.log(rdata); layer.close(loadT); if(rdata.status){ $("#openJK").html("") @@ -136,8 +134,7 @@ function getStatus(){ $("#saveDay").val(rdata.day) },'json'); } - -getStatus() +getStatus(); //设置监控状态 function setControl(act){ diff --git a/route/static/app/firewall.js b/route/static/app/firewall.js index e69948513..151bf9dfd 100755 --- a/route/static/app/firewall.js +++ b/route/static/app/firewall.js @@ -16,7 +16,7 @@ setTimeout(function(){ $(function(){ // start $.post('/firewall/get_www_path',function(data){ - var html ='Web日志:点击进入日志目录\ + var html ='日志目录\ 0KB\ '; $('#firewall_weblog').html(html); diff --git a/route/static/app/public.js b/route/static/app/public.js index 9977aba71..a212e1dfc 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -87,8 +87,6 @@ function repeatPwd(a) { $("#MyPassword").val(randomStrPwd(a)) } - - function GetBakPost(b) { $(".baktext").hide().prev().show(); var c = $(".baktext").attr("data-id"); @@ -679,119 +677,7 @@ $("#dologin").click(function() { return false }); -function setPassword(a) { - if(a == 1) { - p1 = $("#p1").val(); - p2 = $("#p2").val(); - if(p1 == "" || p1.length < 8) { - layer.msg(lan.bt.pass_err_len, { - icon: 2 - }); - return - } - - //准备弱口令匹配元素 - var checks = ['admin888','123123123','12345678','45678910','87654321','asdfghjkl','password','qwerqwer']; - pchecks = 'abcdefghijklmnopqrstuvwxyz1234567890'; - for(var i=0;i
"+lan.public.pass+"
"+lan.bt.pass_re+"
"+lan.bt.pass_rep_btn+"
" - }); -} - -function randPwd(){ - var pwd = RandomStrPwd(12); - $("#p1").val(pwd); - $("#p2").val(pwd); - layer.msg(lan.bt.pass_rep_ps,{time:2000}) -} - -function setUserName(a) { - if(a == 1) { - p1 = $("#p1").val(); - p2 = $("#p2").val(); - if(p1 == "" || p1.length < 3) { - layer.msg(lan.bt.user_len, { - icon: 2 - }); - return - } - if(p1 != p2) { - layer.msg(lan.bt.user_err_re, { - icon: 2 - }); - return - } - $.post("/config?action=setUsername", "username1=" + encodeURIComponent(p1) + "&username2=" + encodeURIComponent(p2), function(b) { - if(b.status) { - layer.closeAll(); - layer.msg(b.msg, { - icon: 1 - }); - $("input[name='username_']").val(p1) - } else { - layer.msg(b.msg, { - icon: 2 - }) - } - }); - return - } - layer.open({ - type: 1, - area: "290px", - title: lan.bt.user_title, - closeBtn: 2, - shift: 5, - shadeClose: false, - content: "
"+lan.bt.user+"
"+lan.bt.pass_re+"
" - }) -} var openWindow = null; var downLoad = null; var speed = null; @@ -877,208 +763,6 @@ function setSelectChecked(c, d) { } } getTaskCount(); -function RecInstall() { - $.post("/ajax?action=GetSoftList", "", function(l){ - var c = ""; - var g = ""; - var e = ""; - for(var h = 0; h < l.length; h++) { - if(l[h].name == "Tomcat") { - continue - } - var o = ""; - var m = ""; - for(var b = 0; b < l[h].versions.length; b++) { - var d = ""; - if((l[h].name == "PHP" && (l[h].versions[b].version == "5.4" || l[h].versions[b].version == "54")) || (l[h].name == "MySQL" && l[h].versions[b].version == "5.5") || (l[h].name == "phpMyAdmin" && l[h].versions[b].version == "4.4")) { - d = "selected"; - m = "" - } - o += "" - } - var f = "
  • " + m + "
  • "; - if(l[h].name == "Nginx") { - c = f - } else { - if(l[h].name == "Apache") { - g = f - } else { - e += f - } - } - } - c += e; - g += e; - g = g.replace(new RegExp(/(data_)/g), "apache_").replace(new RegExp(/(select_)/g), "apache_select_"); - var k = layer.open({ - type: 1, - title: lan.bt.install_title, - area: ["658px", "423px"], - closeBtn: 2, - shadeClose: false, - content: "

    "+lan.bt.install_ps+" "+lan.bt.install_s+" "+lan.bt.install_s1+"

    "+lan.bt.install_lnmp+"

      " + c + "

    "+lan.bt.install_type+":

    "+lan.bt.install_key+"

    LAMP

      " + g + "

    "+lan.bt.install_type+":

    一键安装
    " - }); - $(".fangshi input").click(function() { - $(this).attr("checked", "checked").parent().siblings().find("input").removeAttr("checked") - }); - $(".sl-s-info").change(function() { - var p = $(this).find("option:selected").text(); - var n = $(this).attr("id"); - p = p.toLowerCase(); - $(this).parents("li").find("input").attr("data-info", p) - }); - $("#apache_select_PHP").change(function() { - var n = $(this).val(); - j(n, "apache_select_", "apache_") - }); - $("#select_PHP").change(function() { - var n = $(this).val(); - j(n, "select_", "data_") - }); - - function j(p, r, q) { - var n = "4.4"; - switch(p) { - case "5.2": - n = "4.0"; - break; - case "5.3": - n = "4.0"; - break; - case "5.4": - n = "4.4"; - break; - case "5.5": - n = "4.4"; - break; - default: - n = "4.7" - } - $("#" + r + "phpMyAdmin option[value='" + n + "']").attr("selected", "selected").siblings().removeAttr("selected"); - $("#" + r + "_phpMyAdmin").attr("data-info", "phpmyadmin " + n) - } - $("#select_MySQL,#apache_select_MySQL").change(function() { - var n = $(this).val(); - a(n) - }); - - $("#apache_select_Apache").change(function(){ - var apacheVersion = $(this).val(); - if(apacheVersion == '2.2'){ - layer.msg(lan.bt.install_apache22); - }else{ - layer.msg(lan.bt.install_apache24); - } - }); - - $("#apache_select_PHP").change(function(){ - var apacheVersion = $("#apache_select_Apache").val(); - var phpVersion = $(this).val(); - if(apacheVersion == '2.2'){ - if(phpVersion != '5.2' && phpVersion != '5.3' && phpVersion != '5.4'){ - layer.msg(lan.bt.insatll_s22+'PHP-' + phpVersion,{icon:5}); - $(this).val("5.4"); - $("#apache_PHP").attr('data-info','php 5.4'); - return false; - } - }else{ - if(phpVersion == '5.2'){ - layer.msg(lan.bt.insatll_s24+'PHP-' + phpVersion,{icon:5}); - $(this).val("5.4"); - $("#apache_PHP").attr('data-info','php 5.4'); - return false; - } - } - }); - - function a(n) { - memSize = getCookie("memSize"); - max = 64; - msg = "64M"; - switch(n) { - case "5.1": - max = 256; - msg = "256M"; - break; - case "5.7": - max = 1500; - msg = "2GB"; - break; - case "5.6": - max = 800; - msg = "1GB"; - break; - case "AliSQL": - max = 800; - msg = "1GB"; - break; - case "mariadb_10.0": - max = 800; - msg = "1GB"; - break; - case "mariadb_10.1": - max = 1500; - msg = "2GB"; - break - } - if(memSize < max) { - layer.msg( lan.bt.insatll_mem.replace("{1}",msg).replace("{2}",n), { - icon: 5 - }) - } - } - var de = null; - $(".onekey").click(function() { - if(de) return; - var v = $(this).prev().find("input").eq(0).prop("checked") ? "1" : "0"; - var r = $(this).parents(".rec-box-con").find(".rec-list li").length; - var n = ""; - var q = ""; - var p = ""; - var x = ""; - var s = ""; - de = true; - for(var t = 0; t < r; t++) { - var w = $(this).parents(".rec-box-con").find("ul li").eq(t); - var u = w.find("input"); - if(u.prop("checked")) { - n += u.attr("data-info") + "," - } - } - q = n.split(","); - loadT = layer.msg(lan.bt.install_to, { - icon: 16, - time: 0, - shade: [0.3, "#000"] - }); - for(var t = 0; t < q.length - 1; t++) { - p = q[t].split(" ")[0].toLowerCase(); - x = q[t].split(" ")[1]; - s = "name=" + p + "&version=" + x + "&type=" + v + "&id=" + (t + 1); - $.ajax({ - url: "/files?action=InstallSoft", - data: s, - type: "POST", - async: false, - success: function(y) {} - }); - } - layer.close(loadT); - layer.close(k); - setTimeout(function() { - getTaskCount() - }, 2000); - layer.msg(lan.bt.install_ok, { - icon: 1 - }); - setTimeout(function() { - task() - }, 1000) - }); - InstallTips(); - fly("onekey") - }) -} function jump() { layer.closeAll(); @@ -1358,7 +1042,7 @@ function remind(a){ } -function GetReloads() { +function getReloads() { var a = 0; var mm = $(".bt-w-menu .bgw").html() if(mm == undefined || mm.indexOf(lan.bt.task_list) == -1) { @@ -1477,8 +1161,6 @@ function check_login(){ }); } - - //登陆跳转 function to_login(){ layer.confirm('您的登陆状态已过期,请重新登陆!',{title:'会话已过期',icon:2,closeBtn: 1,shift: 5},function(){ @@ -1502,7 +1184,6 @@ $(function(){ },60000); }); - function asyncLoadImage(obj, url){ if (typeof(url) == 'undefined'){ diff --git a/route/templates/default/config.html b/route/templates/default/config.html index c43d4120c..ba9cbcbb9 100755 --- a/route/templates/default/config.html +++ b/route/templates/default/config.html @@ -22,27 +22,38 @@

    设置

    -
    -

    为了提高安全,请修改别名、默认端口、面板用户和密码!

    +

    + + 为了提高安全,请修改别名、默认端口、面板用户和密码!

    -
    +

    - 别名 + 别名 MDWEB面板

    - 面板端口 - 建议端口范围8888 - 65535 + 面板端口 + 建议端口范围7200 - 65535

    +

    - 域名 + 安全入口 + 修改 + 面板管理入口,设置后只能通过指定安全入口登录面板,如: /abc +

    +

    + 域名 为面板绑定一个访问域名;注意:一旦绑定域名,只能通过域名访问面板!

    -

    授权IP设置访问授权IP,多个请使用逗号(,)隔开;注意:一旦设置授权IP,只有指定IP的电脑能访问面板!

    +

    + 授权IP + + 设置访问授权IP,多个请使用逗号(,)隔开;注意:一旦设置授权IP,只有指定IP的电脑能访问面板! +

    默认建站目录 @@ -61,14 +72,14 @@ 默认为外网IP,若您在本地虚拟机测试,请填写虚拟机内网IP!

    - +

    服务器时间 同步

    面板用户 - 修改 + 修改

    面板密码 @@ -81,126 +92,6 @@

    - diff --git a/route/templates/default/firewall.html b/route/templates/default/firewall.html index 8881b1117..723aeebd8 100755 --- a/route/templates/default/firewall.html +++ b/route/templates/default/firewall.html @@ -87,7 +87,6 @@

    防火墙

    -