From 5217c1fc78b883ed45954a07b43d950053c35a58 Mon Sep 17 00:00:00 2001 From: jose <627622230@qq.com> Date: Fri, 1 Nov 2019 11:43:34 +0800 Subject: [PATCH] update 6.3.3 --- BTPanel/__init__.py | 206 ++++----- .../static/codemirror/addon/search/search.js | 2 +- BTPanel/static/css/site.css | 85 +++- BTPanel/static/js/config.js | 64 ++- BTPanel/static/js/crontab.js | 2 +- BTPanel/static/js/database.js | 7 +- BTPanel/static/js/files.js | 156 +++---- BTPanel/static/js/index.js | 16 +- BTPanel/static/js/public.js | 394 ++++++++---------- BTPanel/static/js/public_backup.js | 9 +- BTPanel/static/js/site.js | 12 + BTPanel/static/js/soft.js | 15 +- BTPanel/static/language/English/template.json | 4 +- BTPanel/templates/default/config.html | 4 +- BTPanel/templates/default/database.html | 2 +- BTPanel/templates/default/files.html | 4 +- BTPanel/templates/default/firewall.html | 3 +- BTPanel/templates/default/ftp.html | 5 +- BTPanel/templates/default/index.html | 8 +- BTPanel/templates/default/layout.html | 43 +- BTPanel/templates/default/site.html | 4 +- class/ajax.py | 3 +- class/common.py | 13 +- class/config.py | 35 +- class/crontab.py | 32 +- class/data.py | 2 +- class/database.py | 9 +- class/files.py | 47 ++- class/jobs.py | 257 ++---------- class/panelAuth.py | 2 +- class/panelDnsapi.py | 13 +- class/panelLets.py | 19 +- class/panelPlugin.py | 60 ++- class/panelSite.py | 63 +-- class/plugin_deployment.py | 2 +- class/public.py | 88 +++- class/site_dir_auth.py | 23 +- class/ssh_terminal.py | 199 +++++++++ class/system.py | 16 +- class/userlogin.py | 7 +- runconfig.py | 26 +- tools.py | 1 + 42 files changed, 1075 insertions(+), 887 deletions(-) create mode 100644 class/ssh_terminal.py diff --git a/BTPanel/__init__.py b/BTPanel/__init__.py index d25c74ea..6616b8a8 100644 --- a/BTPanel/__init__.py +++ b/BTPanel/__init__.py @@ -9,7 +9,7 @@ import sys,json,os,time,logging,re if sys.version_info[0] != 2: from imp import reload -sys.path.insert(0,'class/') +sys.path.insert(0,'/www/server/panel/class/') import public from flask import Flask app = Flask(__name__,template_folder="templates/" + public.GetConfigValue('template')) @@ -19,6 +19,7 @@ from flask_session import Session from werkzeug.contrib.cache import SimpleCache from werkzeug.wrappers import Response from flask_socketio import SocketIO,emit,send +from threading import Lock dns_client = None app.config['DEBUG'] = os.path.exists('data/debug.pl') @@ -37,11 +38,11 @@ cache = SimpleCache() socketio = SocketIO() socketio.init_app(app) -import common,db,jobs,uuid +import common,db,jobs,uuid,ssh_terminal jobs.control_init() app.secret_key = uuid.UUID(int=uuid.getnode()).hex[-12:] local_ip = None - +my_terms = {} try: from flask_sqlalchemy import SQLAlchemy @@ -67,7 +68,10 @@ app.config['SESSION_COOKIE_NAME'] = "BT_PANEL_6" app.config['PERMANENT_SESSION_LIFETIME'] = 86400 Session(app) -if s_sqlite: sdb.create_all() + +if s_sqlite: + sdb.create_all() + public.ExecShell("chmod 600 /dev/shm/session.db") from datetime import datetime import socket @@ -89,11 +93,67 @@ def service_status(): return 'True' + +@socketio.on('connect') +def socket_connect(msg=None): + if not check_login(): + emit('server_response',{'data':public.getMsg('111')}) + return False + +@socketio.on('webssh') +def webssh(msg): + if not check_login(): + session.clear() + emit('server_response',"Panel session is lost, please re-login panel!") + return None + if not 'ssh_obj' in session: + session['ssh_obj'] = ssh_terminal.ssh_terminal() + session['ssh_obj'].send(msg) + + +@app.route('/term_open',methods=method_all) +def term_open(): + comReturn = comm.local() + if comReturn: return comReturn + args = get_input() + if 'get_ssh_info' in args: + key = 'ssh_' + args['host'] + if key in session: + return public.getJson(session[key]),json_header + return public.returnMsg(False,'Acquisition failed!') + session['ssh_info'] = json.loads(args.data) + key = 'ssh_' + session['ssh_info']['host'] + session[key] = session['ssh_info'] + s_file = '/www/server/panel/config/t_info.json' + if 'is_save' in session['ssh_info']: + public.writeFile(s_file,public.de_hexb(json.dumps(session['ssh_info']))) + public.set_mode(s_file,600) + else: + if os.path.exists(s_file): os.remove(s_file) + return public.returnJson(True,'Successful setup!'); + +@app.route('/reload_mod',methods=method_all) +def reload_mod(): + comReturn = comm.local() + if comReturn: return comReturn + args = get_input() + mod_name = None + if 'mod_name' in args: + mod_name = args.mod_name + result = public.reload_mod(mod_name) + if result: return public.returnJson(True,result),json_header + return public.returnJson(False,'Reload failure!'),json_header + @app.before_request def request_check(): if not request.path in ['/safe','/hook','/public']: ip_check = public.check_ip_panel() if ip_check: return ip_check + + if request.path.find('/static/') != -1 or request.path == '/code': + if not 'login' in session and not 'admin_auth' in session: + session.clear() + return abort(401) domain_check = public.check_domain_panel() if domain_check: return domain_check if public.is_local(): @@ -120,7 +180,9 @@ def request_end(reques = None): def send_authenticated(): global local_ip if not local_ip: local_ip = public.GetLocalIp() - return Response('', 401,{'WWW-Authenticate': 'Basic realm="%s"' % local_ip.strip()}) + result = Response('', 401,{'WWW-Authenticate': 'Basic realm="%s"' % local_ip.strip()}) + if not 'login' in session and not 'admin_auth' in session: session.clear() + return result @app.route('/',methods=method_all) def home(): @@ -462,7 +524,7 @@ def config(pdata = None): if public.is_local(): data['is_local'] = 'checked' return render_template( 'config.html',data=data) import config - defs = ('get_qrcode_data','check_two_step','set_two_step_auth','get_key','get_php_session_path','set_php_session_path','get_cert_source','set_local','set_debug','get_panel_error_logs','clean_panel_error_logs','get_basic_auth_stat','set_basic_auth','get_cli_php_version','get_tmp_token','set_cli_php_version','DelOldSession', 'GetSessionCount', 'SetSessionConf', 'GetSessionConf','get_ipv6_listen','set_ipv6_status','GetApacheValue','SetApacheValue','GetNginxValue','SetNginxValue','get_token','set_token','set_admin_path','is_pro','get_php_config','get_config','SavePanelSSL','GetPanelSSL','GetPHPConf','SetPHPConf','GetPanelList','AddPanelInfo','SetPanelInfo','DelPanelInfo','ClickPanelInfo','SetPanelSSL','SetTemplates','Set502','setPassword','setUsername','setPanel','setPathInfo','setPHPMaxSize','getFpmConfig','setFpmConfig','setPHPMaxTime','syncDate','setPHPDisable','SetControl','ClosePanel','AutoUpdatePanel','SetPanelLock') + defs = ('set_coll_open','get_qrcode_data','check_two_step','set_two_step_auth','get_key','get_php_session_path','set_php_session_path','get_cert_source','set_local','set_debug','get_panel_error_logs','clean_panel_error_logs','get_basic_auth_stat','set_basic_auth','get_cli_php_version','get_tmp_token','set_cli_php_version','DelOldSession', 'GetSessionCount', 'SetSessionConf', 'GetSessionConf','get_ipv6_listen','set_ipv6_status','GetApacheValue','SetApacheValue','GetNginxValue','SetNginxValue','get_token','set_token','set_admin_path','is_pro','get_php_config','get_config','SavePanelSSL','GetPanelSSL','GetPHPConf','SetPHPConf','GetPanelList','AddPanelInfo','SetPanelInfo','DelPanelInfo','ClickPanelInfo','SetPanelSSL','SetTemplates','Set502','setPassword','setUsername','setPanel','setPathInfo','setPHPMaxSize','getFpmConfig','setFpmConfig','setPHPMaxTime','syncDate','setPHPDisable','SetControl','ClosePanel','AutoUpdatePanel','SetPanelLock') return publicObject(config.config(),defs,None,pdata); @app.route('/ajax',methods=method_all) @@ -570,6 +632,7 @@ def panel_public(): if not public.path_safe_check("%s/%s" % (get.name,get.fun)): return abort(404) if get.fun in ['scan_login', 'login_qrcode', 'set_login', 'is_scan_ok', 'blind','static']: if get.fun == 'static': + if not 'filename' in get: return abort(404) if not public.path_safe_check("%s" % (get.filename)): return abort(404) s_file = '/www/server/panel/BTPanel/static/' + get.filename if s_file.find('..') != -1 or s_file.find('./') != -1: return abort(404) @@ -598,6 +661,7 @@ def panel_public(): comm.checkWebType() comm.GetOS() result = plu.a(get) + session.clear() return public.getJson(result),json_header @app.route('/favicon.ico',methods=method_get) @@ -661,7 +725,9 @@ def panel_other(name=None,fun = None,stype=None): comReturn = comm.local() if comReturn: if not is_php: - if not hasattr(plu,'_check'): return public.returnJson(False,'SPECIFY_PLUG_ERR'),json_header + if not hasattr(plu,'_check'): + session.clear() + return public.returnJson(False,'SPECIFY_PLUG_ERR'),json_header checks = plu._check(args) r_type = type(checks) if r_type == Response: return checks @@ -738,6 +804,7 @@ def panel_hook(): if not os.path.exists('plugin/webhook'): return public.getJson(public.returnMsg(False,'INIT_WEBHOOK_ERR')); sys.path.append('plugin/webhook'); import webhook_main + session.clear() return public.getJson(webhook_main.webhook_main().RunHook(get)); @app.route('/safe',methods=method_all) @@ -760,13 +827,16 @@ def panel_safe(): if not hasattr(s,get.data['action']): return public.returnJson(False,'INIT_FUN_NOT_EXISTS'); defs = ('GetServerInfo','add_ssh_limit','remove_ssh_limit','get_ssh_limit','get_login_log','get_panel_limit','add_panel_limit','remove_panel_limit','close_ssh_limit','close_panel_limit','get_system_info','get_service_info','get_ssh_errorlogin') if not get.data['action'] in defs: return 'False'; - return public.getJson(eval('s.' + get.data['action'] + '(get)')); + result = public.getJson(eval('s.' + get.data['action'] + '(get)')); + session.clear() + return result @app.route('/install',methods=method_all) def install(): if public.M('config').where("id=?",('1',)).getField('status') == 1: if os.path.exists('install.pl'): os.remove('install.pl'); + session.clear() return redirect('/login') ret_login = os.path.join('/',admin_path) if admin_path == '/' or admin_path == '/bt': ret_login = '/login' @@ -863,122 +933,6 @@ def panel_cloud(): if download_url.find('http') != 0:download_url = 'http://' + download_url return redirect(download_url) -ssh = None -shell = None -try: - import paramiko - ssh = paramiko.SSHClient() -except: - public.ExecShell('pip install paramiko==2.0.2 &') - -@socketio.on('connect') -def socket_connect(msg=None): - if not check_login(): - emit('server_response',{'data':public.getMsg('111')}) - return False - -@socketio.on('webssh') -def webssh(msg): - if not check_login(msg['x_http_token']): - emit('server_response',{'data':public.getMsg('INIT_WEBSSH_LOGOUT')}) - return None - - global shell,ssh - ssh_success = True - if type(msg['data']) == dict: - if 'ssh_user' in msg['data']: - connect_ssh(msg['data']['ssh_user'].strip(),msg['data']['ssh_passwd'].strip()) - if not shell: ssh_success = connect_ssh() - if not shell: - emit('server_response',{'data':public.getMsg('INIT_WEBSSH_CONN_ERR')}) - return; - if shell.exit_status_ready(): ssh_success = connect_ssh() - if not ssh_success: - emit('server_response',{'data':public.getMsg('INIT_WEBSSH_CONN_ERR')}) - return; - shell.send(msg['data']) - time.sleep(0.005) - recv = shell.recv(4096) - emit('server_response',{'data':recv.decode("utf-8")}) - -def connect_ssh(user=None,passwd=None): - global shell,ssh - pkey = '/root/.ssh/id_rsa_bt' - if not os.path.exists('/root/.ssh/authorized_keys') or not os.path.exists(pkey): - create_rsa() - try: - if not user: - key=paramiko.RSAKey.from_private_key_file(pkey) - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - try: - if not user: - ssh.connect('127.0.0.1', public.GetSSHPort(),pkey=key) - else: - ssh.connect('127.0.0.1', public.GetSSHPort(),username=user,password=passwd) - except: - if public.GetSSHStatus(): - try: - if not user: - ssh.connect('localhost', public.GetSSHPort(),pkey=key) - else: - ssh.connect('localhost', public.GetSSHPort(),username=user,password=passwd) - except: - create_rsa() - return False; - import firewalls - fw = firewalls.firewalls() - get = common.dict_obj() - ssh_status = fw.GetSshInfo(get)['status'] - if not ssh_status: - get.status = '0'; - fw.SetSshStatus(get) - - if not user: - ssh.connect('127.0.0.1', public.GetSSHPort(),pkey=key) - else: - ssh.connect('127.0.0.1', public.GetSSHPort(),username=user,password=passwd) - - if not ssh_status: - get.status = '1'; - fw.SetSshStatus(get); - shell = ssh.invoke_shell(term='xterm', width=100, height=29) - shell.setblocking(0) - return True - except: - shell = None - return False - -def create_rsa(): - id_ras = '/root/.ssh/id_rsa_bt' - a_keys = '/root/.ssh/authorized_keys' - if not os.path.exists(a_keys) or not os.path.exists(id_ras): - public.ExecShell("rm -f /root/.ssh/id_rsa_bt*") - public.ExecShell('ssh-keygen -q -t rsa -P "" -f /root/.ssh/id_rsa_bt') - public.ExecShell('cat /root/.ssh/id_rsa_bt.pub >> /root/.ssh/authorized_keys') - else: - id_ras_pub = '/root/.ssh/id_rsa_bt.pub' - if os.path.exists(id_ras_pub): - pub_body = public.readFile(id_ras_pub) - keys_body = public.readFile(a_keys) - if keys_body.find(pub_body) == -1: - public.ExecShell('cat /root/.ssh/id_rsa_bt.pub >> /root/.ssh/authorized_keys') - public.ExecShell('chmod 600 /root/.ssh/authorized_keys') - -@socketio.on('connect_event') -def connected_msg(msg): - if not check_login(): - emit('server_response',{'data':public.getMsg('INIT_WEBSSH_LOGOUT')}) - return None - global shell - if not shell: connect_ssh() - if shell: - try: - recv = shell.recv(8192) - emit('server_response',{'data':recv.decode("utf-8")}) - except: - pass - - def check_csrf(): if app.config['DEBUG']: return True request_token = request.cookies.get('request_token') @@ -1002,6 +956,10 @@ def publicObject(toObject,defs,action=None,get = None): if get.path.find('./') != -1: return public.ReturnJson(False,public.GetMsg("UNSAFE_PATH")),json_header if get.path.find('->') != -1: get.path = get.path.split('->')[0].strip(); + if hasattr(get,'sfile'): + get.sfile = get.sfile.replace('//','/').replace('\\','/'); + if hasattr(get,'dfile'): + get.dfile = get.dfile.replace('//','/').replace('\\','/'); if hasattr(toObject,'site_path_check'): if not toObject.site_path_check(get): return public.ReturnJson(False,'Excessive operation!'),json_header diff --git a/BTPanel/static/codemirror/addon/search/search.js b/BTPanel/static/codemirror/addon/search/search.js index c6598761..b7d7fe1c 100644 --- a/BTPanel/static/codemirror/addon/search/search.js +++ b/BTPanel/static/codemirror/addon/search/search.js @@ -1 +1 @@ -(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],a)}else{a(CodeMirror)}}})(function(n){function k(w,v){if(typeof w=="string"){w=new RegExp(w.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),v?"gi":"g")}else{if(!w.global){w=new RegExp(w.source,w.ignoreCase?"gi":"g")}}return{token:function(y){w.lastIndex=y.pos;var x=w.exec(y.string);if(x&&x.index==y.pos){y.pos+=x[0].length||1;return"searching"}else{if(x){y.pos=x.index}else{y.skipToEnd()}}}}}function j(){this.posFrom=this.posTo=this.lastQuery=this.query=null;this.overlay=null}function s(v){return v.state.search||(v.state.search=new j())}function e(v){return typeof v=="string"&&v==v.toLowerCase()}function b(v,w,x){return v.getSearchCursor(w,x,e(w))}function d(v,y,z,w,x){v.openDialog(y,w,{value:z,selectValueOnOpen:true,closeOnEnter:false,onClose:function(){q(v)},onKeyDown:x})}function p(v,y,w,z,x){if(v.openDialog){v.openDialog(y,x,{value:z,selectValueOnOpen:true})}else{x(prompt(w,z))}}function l(w,y,x,v){if(w.openConfirm){w.openConfirm(y,v)}else{if(confirm(x)){v[0]()}}}function i(v){return v.replace(/\\(.)/g,function(w,x){if(x=="n"){return"\n"}if(x=="r"){return"\r"}return x})}function h(w){var v=w.match(/^\/(.*)\/([a-z]*)$/);if(v){try{w=new RegExp(v[1],v[2].indexOf("i")==-1?"":"i")}catch(x){}}else{w=i(w)}if(typeof w=="string"?w=="":w.test("")){w=/x^/}return w}var u='搜索: (回车继续检索下一个)
X
';function t(v,x,w){x.queryText=w;x.query=h(w);v.removeOverlay(x.overlay,e(x.query));x.overlay=k(x.query,e(x.query));v.addOverlay(x.overlay);if(v.showMatchesOnScrollbar){if(x.annotate){x.annotate.clear();x.annotate=null}x.annotate=v.showMatchesOnScrollbar(x.query,e(x.query))}}function m(v,y,x,z){var C=s(v);if(C.query){return f(v,y)}var B=v.getSelection()||C.lastQuery;if(x&&v.openDialog){var w=null;var A=function(E,D){n.e_stop(D);if(!E){return}if(E!=C.queryText){t(v,C,E);C.posFrom=C.posTo=v.getCursor()}if(w){w.style.opacity=1}f(v,D.shiftKey,function(F,H){var G;if(H.line<3&&document.querySelector&&(G=v.display.wrapper.querySelector(".CodeMirror-dialog"))&&G.getBoundingClientRect().bottom-4>v.cursorCoords(H,"window").top){(w=G).style.opacity=0.4}})};d(v,u,B,A,function(E,G){var D=n.keyName(E);var F=n.keyMap[v.getOption("keyMap")][D];if(!F){F=v.getOption("extraKeys")[D]}if(F=="findNext"||F=="findPrev"||F=="findPersistentNext"||F=="findPersistentPrev"){n.e_stop(E);t(v,s(v),G);v.execCommand(F)}else{if(F=="find"||F=="findPersistent"){n.e_stop(E);A(G,E)}}});if(z&&B){t(v,C,B);f(v,y)}}else{p(v,u,"Search for:",B,function(D){if(D&&!C.query){v.operation(function(){t(v,C,D);C.posFrom=C.posTo=v.getCursor();f(v,y)})}})}}function f(v,w,x){v.operation(function(){var y=s(v);var z=b(v,y.query,w?y.posFrom:y.posTo);if(!z.find(w)){z=b(v,y.query,w?n.Pos(v.lastLine()):n.Pos(v.firstLine(),0));if(!z.find(w)){return}}v.setSelection(z.from(),z.to());v.scrollIntoView({from:z.from(),to:z.to()},20);y.posFrom=z.from();y.posTo=z.to();if(x){x(z.from(),z.to())}})}function q(v){v.operation(function(){var w=s(v);w.lastQuery=w.query;if(!w.query){return}w.query=w.queryText=null;v.removeOverlay(w.overlay);if(w.annotate){w.annotate.clear();w.annotate=null}})}var a=' (Use /re/ syntax for regexp search)';var g='到: ';var o="替换? ";function c(v,w,x){v.operation(function(){for(var z=b(v,w);z.findNext();){if(typeof w!="string"){var y=v.getRange(z.from(),z.to()).match(w);z.replace(x.replace(/\$(\d)/g,function(A,B){return y[B]}))}else{z.replace(x)}}})}function r(v,x){if(v.getOption("readOnly")){return}var y=v.getSelection()||s(v).lastQuery;var w=x?"全部替换:":"替换:";p(v,w+a,w,y,function(z){if(!z){return}z=h(z);p(v,g,"更换:","",function(D){D=i(D);if(x){c(v,z,D)}else{q(v);var C=b(v,z,v.getCursor("from"));var B=function(){var F=C.from(),E;if(!(E=C.findNext())){C=b(v,z);if(!(E=C.findNext())||(F&&C.from().line==F.line&&C.from().ch==F.ch)){return}}v.setSelection(C.from(),C.to());v.scrollIntoView({from:C.from(),to:C.to()});l(v,o,"替换?",[function(){A(E)},B,function(){c(v,z,D)}])};var A=function(E){C.replace(typeof z=="string"?D:D.replace(/\$(\d)/g,function(F,G){return E[G]}));B()};B()}})})}n.commands.find=function(v){q(v);m(v)};n.commands.findPersistent=function(v){q(v);m(v,false,true)};n.commands.findPersistentNext=function(v){m(v,false,true,true)};n.commands.findPersistentPrev=function(v){m(v,true,true,true)};n.commands.findNext=m;n.commands.findPrev=function(v){m(v,true)};n.commands.clearSearch=q;n.commands.replace=r;n.commands.replaceAll=function(v){r(v,true)}});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],a)}else{a(CodeMirror)}}})(function(a){var b=a.Pos;function c(k,i,l,g){this.atOccurrence=false;this.doc=k;if(g==null&&typeof i=="string"){g=false}l=l?k.clipPos(l):b(0,0);this.pos={from:l,to:l};if(typeof i!="string"){if(!i.global){i=new RegExp(i.source,i.ignoreCase?"ig":"g")}this.matches=function(p,t){if(p){i.lastIndex=0;var m=k.getLine(t.line).slice(0,t.ch),r=0,o,s;for(;;){i.lastIndex=r;var q=i.exec(m);if(!q){break}o=q;s=o.index;r=o.index+(o[0].length||1);if(r==m.length){break}}var n=(o&&o[0].length)||0;if(!n){if(s==0&&m.length==0){o=undefined}else{if(s!=k.getLine(t.line).length){n++}}}}else{i.lastIndex=t.ch;var m=k.getLine(t.line),o=i.exec(m);var n=(o&&o[0].length)||0;var s=o&&o.index;if(s+n!=m.length&&!n){n=1}}if(o&&n){return{from:b(t.line,s),to:b(t.line,s+n),match:o}}}}else{var e=i;if(g){i=i.toLowerCase()}var f=g?function(m){return m.toLowerCase()}:function(m){return m};var j=i.split("\n");if(j.length==1){if(!i.length){this.matches=function(){}}else{this.matches=function(o,q){if(o){var p=k.getLine(q.line).slice(0,q.ch),m=f(p);var n=m.lastIndexOf(i);if(n>-1){n=d(p,m,n);return{from:b(q.line,n),to:b(q.line,n+e.length)}}}else{var p=k.getLine(q.line).slice(q.ch),m=f(p);var n=m.indexOf(i);if(n>-1){n=d(p,m,n)+q.ch;return{from:b(q.line,n),to:b(q.line,n+e.length)}}}}}}else{var h=e.split("\n");this.matches=function(n,p){var t=j.length-1;if(n){if(p.line-(j.length-1)=1;--m,--o){if(j[m]!=f(k.getLine(o))){return}}var u=k.getLine(o),q=u.length-h[0].length;if(f(u.slice(q))!=j[0]){return}return{from:b(o,q),to:s}}else{if(p.line+(j.length-1)>k.lastLine()){return}var u=k.getLine(p.line),q=u.length-h[0].length;if(f(u.slice(q))!=j[0]){return}var r=b(p.line,q);for(var o=p.line+1,m=1;mh){--f}else{return f}}}}a.defineExtension("getSearchCursor",function(f,g,e){return new c(this.doc,f,g,e)});a.defineDocExtension("getSearchCursor",function(f,g,e){return new c(this,f,g,e)});a.defineExtension("selectMatches",function(g,f){var e=[];var h=this.getSearchCursor(g,this.getCursor("from"),f);while(h.findNext()){if(a.cmpPos(h.to(),this.getCursor("to"))>0){break}e.push({anchor:h.from(),head:h.to()})}if(e.length){this.setSelections(e,0)}})});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"),require("../dialog/dialog"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror","../dialog/dialog"],a)}else{a(CodeMirror)}}})(function(a){function b(e,i,g,j,h){if(e.openDialog){e.openDialog(i,h,{value:j,selectValueOnOpen:true})}else{h(prompt(g,j))}}var d='Jump to line: (Use line:column or scroll% syntax)';function c(e,g){var f=Number(g);if(/^[-+]/.test(g)){return e.getCursor().line+f}else{return f-1}}a.commands.jumpToLine=function(e){var f=e.getCursor();b(e,d,"Jump to line:",(f.line+1)+":"+f.ch,function(i){if(!i){return}var h;if(h=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(i)){e.setCursor(c(e,h[1]),Number(h[2]))}else{if(h=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(i)){var g=Math.round(e.lineCount()*Number(h[1])/100);if(/^[-+]/.test(h[1])){g=f.line+g+1}e.setCursor(g-1,f.ch)}else{if(h=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(i)){e.setCursor(c(e,h[1]),f.ch)}}}})};a.keyMap["default"]["Alt-G"]="jumpToLine"});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],a)}else{a(CodeMirror)}}})(function(b){b.defineExtension("showMatchesOnScrollbar",function(g,f,e){if(typeof e=="string"){e={className:e}}if(!e){e={}}return new c(this,g,f,e)});function c(e,j,i,h){this.cm=e;this.options=h;var f={listenForChanges:false};for(var k in h){f[k]=h[k]}if(!f.className){f.className="CodeMirror-search-match"}this.annotation=e.annotateScrollbar(f);this.query=j;this.caseFold=i;this.gap={from:e.firstLine(),to:e.lastLine()+1};this.matches=[];this.update=null;this.findMatches();this.annotation.update(this.matches);var g=this;e.on("change",this.changeHandler=function(l,m){g.onChange(m)})}var d=1000;c.prototype.findMatches=function(){if(!this.gap){return}for(var g=0;g=this.gap.to){break}if(f.to.line>=this.gap.from){this.matches.splice(g--,1)}}var h=this.cm.getSearchCursor(this.query,b.Pos(this.gap.from,0),this.caseFold);var e=this.options&&this.options.maxMatches||d;while(h.findNext()){var f={from:h.from(),to:h.to()};if(f.from.line>=this.gap.to){break}this.matches.splice(g++,0,f);if(this.matches.length>e){break}}this.gap=null};function a(e,g,f){if(e<=g){return e}return Math.max(g,e+f)}c.prototype.onChange=function(k){var l=k.from.line;var e=b.changeEnd(k).line;var f=e-k.to.line;if(this.gap){this.gap.from=Math.min(a(this.gap.from,l,f),k.from.line);this.gap.to=Math.max(a(this.gap.to,l,f),k.from.line)}else{this.gap={from:k.from.line,to:e+1}}if(f){for(var h=0;h=n.options.minChars){b(m,q,false,n.options.style)}})}function g(m,r,q){var o=m.getRange(r,q);if(o.match(/^\w+$/)!==null){if(r.ch>0){var p={line:r.line,ch:r.ch-1};var n=m.getRange(p,r);if(n.match(/\W/)===null){return false}}if(q.chv.cursorCoords(H,"window").top){(w=G).style.opacity=0.4}})};d(v,u,B,A,function(E,G){var D=n.keyName(E);var F=n.keyMap[v.getOption("keyMap")][D];if(!F){F=v.getOption("extraKeys")[D]}if(F=="findNext"||F=="findPrev"||F=="findPersistentNext"||F=="findPersistentPrev"){n.e_stop(E);t(v,s(v),G);v.execCommand(F)}else{if(F=="find"||F=="findPersistent"){n.e_stop(E);A(G,E)}}});if(z&&B){t(v,C,B);f(v,y)}}else{p(v,u,"Search for:",B,function(D){if(D&&!C.query){v.operation(function(){t(v,C,D);C.posFrom=C.posTo=v.getCursor();f(v,y)})}})}}function f(v,w,x){v.operation(function(){var y=s(v);var z=b(v,y.query,w?y.posFrom:y.posTo);if(!z.find(w)){z=b(v,y.query,w?n.Pos(v.lastLine()):n.Pos(v.firstLine(),0));if(!z.find(w)){return}}v.setSelection(z.from(),z.to());v.scrollIntoView({from:z.from(),to:z.to()},20);y.posFrom=z.from();y.posTo=z.to();if(x){x(z.from(),z.to())}})}function q(v){v.operation(function(){var w=s(v);w.lastQuery=w.query;if(!w.query){return}w.query=w.queryText=null;v.removeOverlay(w.overlay);if(w.annotate){w.annotate.clear();w.annotate=null}})}var a=' (Use /re/ syntax for regexp search)';var g='To: ';var o="replace? ";function c(v,w,x){v.operation(function(){for(var z=b(v,w);z.findNext();){if(typeof w!="string"){var y=v.getRange(z.from(),z.to()).match(w);z.replace(x.replace(/\$(\d)/g,function(A,B){return y[B]}))}else{z.replace(x)}}})}function r(v,x){if(v.getOption("readOnly")){return}var y=v.getSelection()||s(v).lastQuery;var w=x?"Replace all:":"replace:";p(v,w+a,w,y,function(z){if(!z){return}z=h(z);p(v,g,"Change:","",function(D){D=i(D);if(x){c(v,z,D)}else{q(v);var C=b(v,z,v.getCursor("from"));var B=function(){var F=C.from(),E;if(!(E=C.findNext())){C=b(v,z);if(!(E=C.findNext())||(F&&C.from().line==F.line&&C.from().ch==F.ch)){return}}v.setSelection(C.from(),C.to());v.scrollIntoView({from:C.from(),to:C.to()});l(v,o,"replace?",[function(){A(E)},B,function(){c(v,z,D)}])};var A=function(E){C.replace(typeof z=="string"?D:D.replace(/\$(\d)/g,function(F,G){return E[G]}));B()};B()}})})}n.commands.find=function(v){q(v);m(v)};n.commands.findPersistent=function(v){q(v);m(v,false,true)};n.commands.findPersistentNext=function(v){m(v,false,true,true)};n.commands.findPersistentPrev=function(v){m(v,true,true,true)};n.commands.findNext=m;n.commands.findPrev=function(v){m(v,true)};n.commands.clearSearch=q;n.commands.replace=r;n.commands.replaceAll=function(v){r(v,true)}});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],a)}else{a(CodeMirror)}}})(function(a){var b=a.Pos;function c(k,i,l,g){this.atOccurrence=false;this.doc=k;if(g==null&&typeof i=="string"){g=false}l=l?k.clipPos(l):b(0,0);this.pos={from:l,to:l};if(typeof i!="string"){if(!i.global){i=new RegExp(i.source,i.ignoreCase?"ig":"g")}this.matches=function(p,t){if(p){i.lastIndex=0;var m=k.getLine(t.line).slice(0,t.ch),r=0,o,s;for(;;){i.lastIndex=r;var q=i.exec(m);if(!q){break}o=q;s=o.index;r=o.index+(o[0].length||1);if(r==m.length){break}}var n=(o&&o[0].length)||0;if(!n){if(s==0&&m.length==0){o=undefined}else{if(s!=k.getLine(t.line).length){n++}}}}else{i.lastIndex=t.ch;var m=k.getLine(t.line),o=i.exec(m);var n=(o&&o[0].length)||0;var s=o&&o.index;if(s+n!=m.length&&!n){n=1}}if(o&&n){return{from:b(t.line,s),to:b(t.line,s+n),match:o}}}}else{var e=i;if(g){i=i.toLowerCase()}var f=g?function(m){return m.toLowerCase()}:function(m){return m};var j=i.split("\n");if(j.length==1){if(!i.length){this.matches=function(){}}else{this.matches=function(o,q){if(o){var p=k.getLine(q.line).slice(0,q.ch),m=f(p);var n=m.lastIndexOf(i);if(n>-1){n=d(p,m,n);return{from:b(q.line,n),to:b(q.line,n+e.length)}}}else{var p=k.getLine(q.line).slice(q.ch),m=f(p);var n=m.indexOf(i);if(n>-1){n=d(p,m,n)+q.ch;return{from:b(q.line,n),to:b(q.line,n+e.length)}}}}}}else{var h=e.split("\n");this.matches=function(n,p){var t=j.length-1;if(n){if(p.line-(j.length-1)=1;--m,--o){if(j[m]!=f(k.getLine(o))){return}}var u=k.getLine(o),q=u.length-h[0].length;if(f(u.slice(q))!=j[0]){return}return{from:b(o,q),to:s}}else{if(p.line+(j.length-1)>k.lastLine()){return}var u=k.getLine(p.line),q=u.length-h[0].length;if(f(u.slice(q))!=j[0]){return}var r=b(p.line,q);for(var o=p.line+1,m=1;mh){--f}else{return f}}}}a.defineExtension("getSearchCursor",function(f,g,e){return new c(this.doc,f,g,e)});a.defineDocExtension("getSearchCursor",function(f,g,e){return new c(this,f,g,e)});a.defineExtension("selectMatches",function(g,f){var e=[];var h=this.getSearchCursor(g,this.getCursor("from"),f);while(h.findNext()){if(a.cmpPos(h.to(),this.getCursor("to"))>0){break}e.push({anchor:h.from(),head:h.to()})}if(e.length){this.setSelections(e,0)}})});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"),require("../dialog/dialog"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror","../dialog/dialog"],a)}else{a(CodeMirror)}}})(function(a){function b(e,i,g,j,h){if(e.openDialog){e.openDialog(i,h,{value:j,selectValueOnOpen:true})}else{h(prompt(g,j))}}var d='Jump to line: (Use line:column or scroll% syntax)';function c(e,g){var f=Number(g);if(/^[-+]/.test(g)){return e.getCursor().line+f}else{return f-1}}a.commands.jumpToLine=function(e){var f=e.getCursor();b(e,d,"Jump to line:",(f.line+1)+":"+f.ch,function(i){if(!i){return}var h;if(h=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(i)){e.setCursor(c(e,h[1]),Number(h[2]))}else{if(h=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(i)){var g=Math.round(e.lineCount()*Number(h[1])/100);if(/^[-+]/.test(h[1])){g=f.line+g+1}e.setCursor(g-1,f.ch)}else{if(h=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(i)){e.setCursor(c(e,h[1]),f.ch)}}}})};a.keyMap["default"]["Alt-G"]="jumpToLine"});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],a)}else{a(CodeMirror)}}})(function(b){b.defineExtension("showMatchesOnScrollbar",function(g,f,e){if(typeof e=="string"){e={className:e}}if(!e){e={}}return new c(this,g,f,e)});function c(e,j,i,h){this.cm=e;this.options=h;var f={listenForChanges:false};for(var k in h){f[k]=h[k]}if(!f.className){f.className="CodeMirror-search-match"}this.annotation=e.annotateScrollbar(f);this.query=j;this.caseFold=i;this.gap={from:e.firstLine(),to:e.lastLine()+1};this.matches=[];this.update=null;this.findMatches();this.annotation.update(this.matches);var g=this;e.on("change",this.changeHandler=function(l,m){g.onChange(m)})}var d=1000;c.prototype.findMatches=function(){if(!this.gap){return}for(var g=0;g=this.gap.to){break}if(f.to.line>=this.gap.from){this.matches.splice(g--,1)}}var h=this.cm.getSearchCursor(this.query,b.Pos(this.gap.from,0),this.caseFold);var e=this.options&&this.options.maxMatches||d;while(h.findNext()){var f={from:h.from(),to:h.to()};if(f.from.line>=this.gap.to){break}this.matches.splice(g++,0,f);if(this.matches.length>e){break}}this.gap=null};function a(e,g,f){if(e<=g){return e}return Math.max(g,e+f)}c.prototype.onChange=function(k){var l=k.from.line;var e=b.changeEnd(k).line;var f=e-k.to.line;if(this.gap){this.gap.from=Math.min(a(this.gap.from,l,f),k.from.line);this.gap.to=Math.max(a(this.gap.to,l,f),k.from.line)}else{this.gap={from:k.from.line,to:e+1}}if(f){for(var h=0;h=n.options.minChars){b(m,q,false,n.options.style)}})}function g(m,r,q){var o=m.getRange(r,q);if(o.match(/^\w+$/)!==null){if(r.ch>0){var p={line:r.line,ch:r.ch-1};var n=m.getRange(p,r);if(n.match(/\W/)===null){return false}}if(q.chTo display the panel API key, click the reset button to regain the new API key.
Note: After the key is reset, the associated key product will be invalid. Please re-add the new key to the product.',{icon:0,time:0,shadeClose:true,shade:0.1}); +} -function SetPanelApi(t_type) { +function SetPanelApi(t_type,index) { var pdata = {} pdata['t_type'] = t_type if (t_type == 3) { pdata['limit_addr'] = $("textarea[name='api_limit_addr']").val() } - var loadT = layer.msg(lan.config.is_submitting, { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.post('/config?action=set_token', pdata, function (rdata) { - if (t_type == 1) { - if (rdata.status) { - $("input[name='panel_token_value']").val(rdata.msg); - layer.msg(lan.config.create_int_key_success, { icon: 1, time: 0, shade: 0.3, shadeClose:true }); - return; - } - } - - layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + if(t_type == 1){ + var bdinding = layer.confirm('Are you sure you want to reset your current key?
After the key is reset, the associated key product will be invalid. Please re-add the new key to the product.',{ + btn:['Confirm','Cancel'], + icon:3, + closeBtn: 2, + title:'Reset key' + },function(){ + var loadT = layer.msg(lan.config.is_submitting, { icon: 16, time: 0, shade: [0.3, '#000'] }); + set_token_req(pdata,function(rdata){ + if (rdata.status) { + $("input[name='panel_token_value']").val(rdata.msg); + layer.msg(lan.config.create_int_key_success, { icon: 1, time: 0, shade: 0.3, shadeClose:true,closeBtn:2}); + }else{ + layer.msg(rdata.msg, { icon: 2}); + } + return false; + }); + }); + return false + } + set_token_req(pdata,function(rdata){ + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); if (rdata.msg == lan.config.open_successfully) { - GetPanelApi(); + if(t_type == 2 && index != '0') GetPanelApi(); } - }) + }); } +function set_token_req(pdata,callback){ + $.post('/config?action=set_token', pdata, function (rdata) { + if(callback) callback(rdata); + }); +} + + + function SetIPv6() { var loadT = layer.msg(lan.config.setting_up, { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/config?action=set_ipv6_status', {}, function (rdata) { diff --git a/BTPanel/static/js/crontab.js b/BTPanel/static/js/crontab.js index 9b450fd1..be587558 100644 --- a/BTPanel/static/js/crontab.js +++ b/BTPanel/static/js/crontab.js @@ -819,7 +819,7 @@ function toBackup(type){ \ '+lan.crontab.save_num+'\ '; - if (sType == 'sites') { + if (sType == 'sites' && sMsg !== lan.crontab.backup_log) { sBody += '

\

'+lan.crontab.exclusion_rule+'
\
'; - $("#fileCon").removeClass("fileList").html(tablehtml); - $("#tipTools").width($("#fileCon").width()); - } - else{ - $("#fileCon").addClass("fileList").html(Body); - $("#tipTools").width($("#fileCon").width()); - } - $("#DirPathPlace input").val(rdata.PATH); - var BarTools = '
\ + $("#fileCon").removeClass("fileList").html(tablehtml); + $("#tipTools").width($("#fileCon")[0].clientWidth - 20); + } + else { + $("#fileCon").addClass("fileList").html(Body); + $("#tipTools").width($("#fileCon")[0].clientWidth - 20); + } + $("#DirPathPlace input").val(rdata.PATH); + var BarTools = '
\ \ @@ -600,9 +600,9 @@ function GetFiles(Path,sort) { } $("#Batch").html(BatchTools); $("#setBox").prop("checked", false); - + $("#BarTools").html(BarTools); - + $("input[name=id]").click(function(){ if($(this).prop("checked")) { $(this).prop("checked", true); @@ -631,7 +631,7 @@ function GetFiles(Path,sort) { if ($(this).prop("checked")) { $("input[name=id]").prop("checked", true); $("#filesBody > tr").addClass("ui-selected"); - + } else { $("input[name=id]").prop("checked", false); $("#filesBody > tr").removeClass("ui-selected"); @@ -690,13 +690,13 @@ function auto_table_width(){ }); if(oldTable_heigth > oldTable){ $('.oldTableShadow,.newTableShadow').show(); - $('.oldTable').css('marginTop','-8px') + $('.oldTable').css('marginTop','0') }else{ $('.oldTableShadow,.newTableShadow').hide(); $('.oldTable').css('marginTop','0') } $('.oldTable').height(oldTable); - $('.oldTable table').css({'marginTop':'-39px'}) + $('.oldTable table').css({ 'marginTop': '-36px' }) } @@ -757,22 +757,22 @@ function showSeclect(){ $("#Batch").html(BatchTools); } } -$("#tipTools").width($(".file-box").width()); -$("#PathPlaceBtn").width($(".file-box").width()-700); -$("#DirPathPlace input").width($(".file-box").width()-700); -if($(window).width()<1160){ - $("#PathPlaceBtn").width(290); +$("#tipTools").width($(".file-box")[0].clientWidth); +$("#PathPlaceBtn").width($(".file-box").width() - 700); +$("#DirPathPlace input").width($(".file-box").width() - 700); +if ($(window).width() < 1160) { + $("#PathPlaceBtn").width(290); } -window.onresize = function(){ - $("#tipTools").width($(".file-box").width()-30); - $("#PathPlaceBtn").width($(".file-box").width()-700); - $("#DirPathPlace input").width($(".file-box").width()-700); - if($(window).width()<1160){ - $("#PathPlaceBtn,#DirPathPlace input").width(290); - } - PathLeft(); - IsDiskWidth() - auto_table_width(); +window.onresize = function () { + $("#tipTools").width($(".file-box")[0].clientWidth); + $("#PathPlaceBtn").width($(".file-box").width() - 700); + $("#DirPathPlace input").width($(".file-box").width() - 700); + if ($(window).width() < 1160) { + $("#PathPlaceBtn,#DirPathPlace input").width(290); + } + PathLeft(); + IsDiskWidth() + auto_table_width(); } function Batch(type,access){ var path = $("#DirPathPlace input").val(); @@ -781,9 +781,9 @@ function Batch(type,access){ var data='path='+path+'&type='+type; var name = 'data'; var datas = [] - + var oldType = getCookie('BatchPaste'); - + for(var i=0;i"+lan.public.the+"
",{icon:16,time:0,shade: [0.3, '#000']}); setTimeout(function(){getSpeed('.myspeed');},1000); $.post('/files?action=SetBatchData',data,function(rdata){ @@ -835,14 +836,14 @@ function BatchPaste(){ var path = $("#DirPathPlace input").val(); var type = getCookie('BatchPaste'); var data = 'type='+type+'&path='+path; - + $.post('/files?action=CheckExistsFiles',{dfile:path},function(result){ if(result.length > 0){ var tbody = ''; for(var i=0;i'+ToSize(result[i].size)+''+getLocalTime(result[i].mtime)+''; } - var mbody = '
\ + var mbody = '
'+lan.files.file_name+''+lan.files.file_size+''+lan.files.last_edit_time+'
\ '+tbody+'\
'+lan.files.file_name+''+lan.files.file_size+''+lan.files.last_edit_time+'
'; SafeMessage(lan.files.will_cover_this_file,mbody,function(){ @@ -854,7 +855,7 @@ function BatchPaste(){ } }); } - + function BatchPasteTo(data,path){ myloadT = layer.msg("
"+lan.public.the+"
",{icon:16,time:0,shade: [0.3, '#000']}); setTimeout(function(){getSpeed('.myspeed');},1000); @@ -866,7 +867,7 @@ function BatchPasteTo(data,path){ }); } function GetExtName(fileName){ - var extArr = fileName.split("."); + var extArr = fileName.split("."); var exts = ['folder','folder-unempty','sql','c','cpp','cs','flv','css','js','htm','html','java','log','mht','php','url','xml','ai','bmp','cdr','gif','ico','jpeg','jpg','JPG','png','psd','webp','ape','avi','flv','mkv','mov','mp3','mp4','mpeg','mpg','rm','rmvb','swf','wav','webm','wma','wmv','rtf','docx','fdf','potm','pptx','txt','xlsb','xlsx','7z','cab','iso','bz2','rar','zip','gz','bt','file','apk','bookfolder','folder','folder-empty','folder-unempty','fromchromefolder','documentfolder','fromphonefolder','mix','musicfolder','picturefolder','videofolder','sefolder','access','mdb','accdb','sql','c','cpp','cs','js','fla','flv','htm','html','java','log','mht','php','url','xml','ai','bmp','cdr','gif','ico','jpeg','jpg','JPG','png','psd','webp','ape','avi','flv','mkv','mov','mp3','mp4','mpeg','mpg','rm','rmvb','swf','wav','webm','wma','wmv','doc','docm','dotx','dotm','dot','rtf','docx','pdf','fdf','ppt','pptm','pot','potm','pptx','txt','xls','csv','xlsm','xlsb','xlsx','7z','gz','cab','iso','rar','zip','bt','file','apk','css']; var extLastName = extArr[extArr.length - 1]; for(var i=0; i\
\ @@ -1114,7 +1115,7 @@ function ExecShell(action){ else{ layer.msg(rdata.msg,{icon:rdata.status?1:2}); } - + }); return; } @@ -1122,7 +1123,7 @@ function ExecShell(action){ type: 1, shift: 5, closeBtn: 2, - area: ['70%','600px'], + area: ['70%','600px'], title: lan.files.shell_title, content: '
\
\ @@ -1134,7 +1135,7 @@ function ExecShell(action){ setTimeout(function(){ outTimeGet(); },1000); - + } var outTime = null; @@ -1171,7 +1172,7 @@ function ReName(type, fileName) { type: 1, shift: 5, closeBtn: 2, - area: '320px', + area: '320px', title: lan.files.file_menu_rename, content: '
\
\ @@ -1250,7 +1251,7 @@ function PasteTo(path,copyName,cutName,fileName){ setCookie('cutFileName', null); return; } - + if (cutName != 'null' && cutName != undefined) { layer.msg(lan.files.mv_the, { icon: 16, @@ -1298,13 +1299,13 @@ function Zip(dirName,submits) { }); return } - + param = dirName; if(dirName.indexOf(',') != -1){ tmp = path.split('/') dirName = path + '/' + tmp[tmp.length-1] } - + var layers = layer.open({ type: 1, shift: 5, @@ -1336,7 +1337,7 @@ function Zip(dirName,submits) { $("#dfile").val(dirName + '.' + z_type); }); },100); - + } function UnZip(fileName,type) { var path = $("#DirPathPlace input").val(); @@ -1354,7 +1355,7 @@ function UnZip(fileName,type) { }); return } - + type = (type == 1) ? 'tar':'zip' var umpass = ''; if(type == 'zip'){ @@ -1459,7 +1460,7 @@ function UploadFiles() { type:1, closeBtn: 2, title:lan.files.up_title, - area: ['500px','500px'], + area: ['500px','500px'], shadeClose:false, content:'
\ \ @@ -1497,9 +1498,9 @@ function SetChmod(action,fileName){ }); return; } - + var toExec = fileName == lan.files.all?'Batch(3,1)':'SetChmod(1,\''+fileName+'\')'; - + $.post('/files?action=GetFileAccess','filename='+encodeURIComponent(fileName),function(rdata){ var layers = layer.open({ type:1, @@ -1552,7 +1553,7 @@ function SetChmod(action,fileName){ $("#access").keyup(function(){ onAccess(); }); - + $("input[type=checkbox]").change(function(){ var idName = ['owner','group','public']; var onacc = ''; @@ -1564,15 +1565,15 @@ function SetChmod(action,fileName){ onacc += access; } $("#access").val(onacc); - + }); }) - + } function onAccess(){ var access = $("#access").val(); - var idName = ['owner','group','public']; + var idName = ['owner','group','public']; for(var n=0;n':' | '); } - layer.tips(d[3] +"
"+ crs, _this.find('.cicle'), { time: 0, tips: [1, '#999'] }); + layer.tips(d[3] + "
" + d[5] + " CPU, " + d[4] + " Core, " + d[4]+" Thread
"+ crs, _this.find('.cicle'), { time: 0, tips: [1, '#999'] }); }, function () { layer.closeAll('tips'); }); @@ -230,7 +230,7 @@ var index = { var load_arr = [{ title: lan.index.run_block, val: 100, color: '#dd2f00' }, { title: lan.index.run_slow, val: 90, color: '#ff9900' }, { title: lan.index.run_normal, val: 70, color: '#20a53a' }, { title: lan.index.run_fluent, val: 30, color: '#20a53a' }]; var _cpubox = $('.cpubox'), _membox = $('.membox'), _loadbox = $('.loadbox') - index.set_val(_cpubox, { usage: net.cpu[0], title: net.cpu[1] + ' ' + lan.index.cpu_core, items: pub_arr }) + index.set_val(_cpubox, { usage: net.cpu[0], title: net.cpu[1]+' '+lan.index.cpu_core, items: pub_arr }) index.set_val(_membox, { usage: (net.mem.memRealUsed * 100 / net.mem.memTotal).toFixed(1), items: pub_arr, title: net.mem.memRealUsed + '/' + net.mem.memTotal + '(MB)' }) bt.set_cookie('memSize', net.mem.memTotal) @@ -262,6 +262,11 @@ var index = { $("#messageError").show(); $("#messageError").append('

' + lan.index.user_warning + ' ['+lan.index.cant_ignore+'] ['+lan.index.edit_now+']

') } + + if (info.isport === true) { + $("#messageError").show(); + $("#messageError").append('

'+lan.index.panel_port_tips+' ['+lan.index.panel_port_tip2+'] ['+lan.index.panel_port_tip3+']

') + } var _system = info.system; $("#info").html(_system); $("#running").html(info.time); @@ -302,6 +307,11 @@ var index = { arr.push({ title: lan.index.already_use, value: item.inodes[1] }) arr.push({ title: lan.index.available, value: item.inodes[2] }) arr.push({ title: lan.index.inode_percent, value: item.inodes[3] }) + arr.push({ title: 'Capacity information', value: '' }) + arr.push({ title: 'Capacity', value: item.size[0] }) + arr.push({ title: 'Used', value: item.size[1] }) + arr.push({ title: 'Available', value: item.size[2] }) + arr.push({ title: 'Usage rate', value: item.size[3] }) obj.masks = arr; data.items.push(obj) } @@ -446,7 +456,9 @@ var index = { }) }, check_update: function () { + var _load = bt.load('Getting updates, please wait...'); bt.system.check_update(function (rdata) { + _load.close(); if (rdata.status === false) { if (!rdata.msg.beta) { bt.msg(rdata); diff --git a/BTPanel/static/js/public.js b/BTPanel/static/js/public.js index ddfa2b0a..12bd73c0 100644 --- a/BTPanel/static/js/public.js +++ b/BTPanel/static/js/public.js @@ -339,11 +339,11 @@ var aceEditor = { break; // 搜索 case 'searchs': - + editor_item.ace.execCommand('find'); break; // 替换 case 'replaces': - + editor_item.ace.execCommand('replace'); break; // 字体 case 'fontSize': @@ -2574,254 +2574,204 @@ function scroll_handle(e){ var scrollTop = this.scrollTop; $(this).find("thead").css({"transform":"translateY("+scrollTop+"px)","position":"relative","z-index":"1"}); } -var clipboard, interval, socket, gterm, ssh_login,term_box; +var clipboard, interval, socket, term, ssh_login,term_box; var pdata_socket = { x_http_token: document.getElementById("request_token_head").getAttribute('token') } -function ssh_login_def() { - pdata_socket['data'] = {}; - pdata_socket['data']['ssh_user'] = $("input[name='ssh_user']").val(); - pdata_socket['data']['ssh_passwd'] = $("input[name='ssh_passwd']").val(); - if (!pdata_socket.data.ssh_user || !pdata_socket.data.ssh_passwd) { - layer.msg('The SSH username and password cannot be empty!'); - return; - } - - layer.close(ssh_login); - socket.emit('webssh', pdata_socket); - gterm.focus(); -} - function web_shell() { var termCols = 100; - var termRows = 29; - var sendTotal = 0; - if(!socket)socket = io.connect(); - var term = new Terminal({ cols: termCols, rows: termRows, screenKeys: true, useStyle: true}); - term.open(); - gterm = term + var termRows = 34; + if (!socket) connect_io() + term = new Terminal({ cols: termCols, rows: termRows, screenKeys: true, useStyle: true }); term.setOption('cursorBlink', true); - socket.on('server_response', function (data) { - if (data.data == "Failed to connect to SSH service!\r\n") { - if ($("input[name='ssh_user']").attr('autocomplete')) return; - var s_body = '
\ -
Username
\ -
Password
\ -
'; - ssh_login = layer.open({ - type: 1, - title: 'Please enter the SSH login account and password', - area: "500px", - closeBtn: 0, - shadeClose: false, - content: s_body - }); + term_box = layer.open({ + type: 1, + title: 'aaPanel terminal', + area: ['920px', '630px'], + closeBtn: 2, + shadeClose: false, + content: '[Set]
', + cancel: function () { + term.destroy(); + }, + success: function () { + term.open(document.getElementById('term')); + } + }); - setTimeout(function removeReadonly() { - $("input[name='ssh_user']").removeAttr('readonly'); - $("input[name='ssh_passwd']").removeAttr('readonly'); - $("input[name='ssh_user']").focus(); + term.on('data', function (data) { + socket.emit('webssh', data); + }); - $("input[name='ssh_passwd']").keydown(function (e) { - if (e.keyCode == 13) { - $('.ssh-login').click(); - } - }); + $(".shell_btn_close").click(function(){ + layer.close(term_box); + term.destroy(); + }) - }, 500); + setTimeout(function () { + socket.emit('webssh', "\u0015"); + socket.emit('webssh', "new_bt_terminal"); + //socket.emit('webssh', "new_bt_terminal"); + term.focus(); + }, 100) +} + + +function connect_io() { + socket = io.connect(); + socket.on('ssh_data', function (data) { + if (data === "\rServer connection failed!\r" || data === "\rWrong user name or password!\r") { + show_ssh_login(0); return; } - term.write(data.data); + term.write(data); - if (data.data == '\r\n'+lan.public.logout+'\r\n' || data.data == lan.public.logout+'\r\n' || data.data == '\r\nlogout\r\n' || data.data == 'logout\r\n') { + if (data == '\r\n登出\r\n' || data == '登出\r\n' || data == '\r\nlogout\r\n' || data == 'logout\r\n') { setTimeout(function () { layer.close(term_box); }, 500); } }); +} - if (socket) { - socket.emit('connect_event', ''); - interval = setInterval(function () { - socket.emit('connect_event', ''); - }, 1000); - } - - term.on('data', function (data) { - pdata_socket['data'] = data; - socket.emit('webssh', pdata_socket); - }); - - - term_box = layer.open({ +function show_ssh_login(is_config) { + if ($("input[name='ssh_user']").attr('autocomplete')) return; + var s_body = '
\ + \ +
IP
\ +
Port
\ +
Username
\ +
Method
\ +
Password
\ + \ +
\ +

Only support login to this server

\ +
'; + ssh_login = layer.open({ type: 1, - title: lan.public.bt_terminal, - area: ['920px','640px'], - closeBtn: 2, + title: is_config?'Please fill in the SSH connection configuration':'Please enter the SSH login account and password', + area: "500px", + closeBtn: 0, shadeClose: false, - content: '
\ -
\ -