def BtcoInstall(self, get): v = public.version() if v[-2] == '.': if v < '6.9.1': public.returnMsg(False, '抱歉,面板当前版本不支持BTCO,请升级面板至最新版') else: if v < '6.9.15': public.returnMsg(False, '抱歉,面板当前版本不支持BTCO,请升级面板至最新版') if not public.GetConfigValue('btco'): initobj = open( '/www/server/panel/BTPanel/templates/default/layout.html', 'r') for initLine in initobj: for btcoin in ['<!--BTCO-->']: if btcoin.upper() in initLine.upper(): self.BtcoIns.append(btcoin) if len(self.BtcoIns) != 0: initobj.close() public.SetConfigValue('btco', True) return public.returnMsg(True, '您已安装过了.') # BTCO 强制跳转写入 BtcoAdd = '<!--BTCO-->\n <script> var a=document.location.toString().split("//");navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)&&("/"==a[1].substring(a[1].indexOf("/"))?window.location.href="/btco/index.html' + '":"/config"==a[1].substring(a[1].indexOf("/"))&&(window.location.href="/btco/index.html#/config' + '")); </script> \n <!--BTCO-->' initCoutent = open( '/www/server/panel/BTPanel/templates/default/layout.html', 'r') BtcoAddIn = initCoutent.read().split("</head>") initCoutent.close() BtcoAddin = open( '/www/server/panel/BTPanel/templates/default/layout.html', 'w') BtcoAddin.write(BtcoAddIn[0] + BtcoAdd + "</head>" + BtcoAddIn[1]) BtcoAddin.close() public.restart_panel() public.SetConfigValue('btco', True) return public.returnMsg(True, '安装成功,感谢支持.') elif public.GetConfigValue('btco'): return public.returnMsg(True, '您已安装过了.') return public.returnMsg(False, '安装失败')
def get_cloud_messages(self, args): #ret = cache.get('get_cloud_messages') #if ret: return public.returnMsg(True,'同步成功1!') data = {} data['version'] = public.version() data['os'] = self.os sUrl = public.GetConfigValue('home') + '/api/wpanel/get_messages' import http_requests http_requests.DEFAULT_TYPE = 'src' info = http_requests.post(sUrl, data).json() # info = json.loads(public.httpPost(sUrl,data)) for x in info: count = public.M('messages').where('level=? and msg=?', ( x['level'], x['msg'], )).count() if count: continue pdata = { "level": x['level'], "msg": x['msg'], "state": 1, "expire": int(time.time()) + (int(x['expire']) * 86400), "addtime": int(time.time()) } public.M('messages').insert(pdata) #cache.set('get_cloud_messages',3600) return public.returnMsg(True, '同步成功!')
def BT_Config(self, get): BTConfig = {} BTConfig['BTTitle'] = public.GetConfigValue('title') BTConfig['BTUser'] = session['username'] BTConfig['BTVersion'] = public.version() BTConfig['BTBeta'] = session['updateInfo']['is_beta'] BTConfig['BTPRO'] = self.is_pro() return BTConfig
def BtcoInstall(self, get): v = public.version() if v[-2] == '.': if v < '6.9.1': public.returnMsg(False, '抱歉,面板当前版本不支持BTCO,请升级面板至最新版') else: if v < '6.9.15': public.returnMsg(False, '抱歉,面板当前版本不支持BTCO,请升级面板至最新版') if not public.GetConfigValue('btco'): initobj = open( '/www/server/panel/BTPanel/templates/default/layout.html', 'r') for initLine in initobj: for btcoin in ['<!--BTCO-->']: if btcoin.upper() in initLine.upper(): self.BtcoIns.append(btcoin) if len(self.BtcoIns) != 0: initobj.close() public.SetConfigValue('btco', True) public.SetConfigValue('btco_init', True) return public.returnMsg(True, '您已安装过了。') # BTCO 强制跳转写入 BtcoAdd = '<!--BTCO-->\n <script> if(navigator.userAgent.match(/mobile/i)){let a=document.location.toString().split("//"),urlArr=["/","/config"],thisUrl=urlArr.indexOf(a[1].substring(a[1].indexOf("/")));if(thisUrl>-1)window.location.href="/btco/index.html#"+urlArr[thisUrl]} </script> \n <!--BTCO-->' initCoutent = open( '/www/server/panel/BTPanel/templates/default/layout.html', 'r') BtcoAddIn = initCoutent.read().split("</head>") initCoutent.close() BtcoAddin = open( '/www/server/panel/BTPanel/templates/default/layout.html', 'w') BtcoAddin.write(BtcoAddIn[0] + BtcoAdd + "</head>" + BtcoAddIn[1]) BtcoAddin.close() public.restart_panel() public.SetConfigValue('btco', True) public.SetConfigValue('btco_init', True) return public.returnMsg(True, '安装成功,感谢支持.') elif public.GetConfigValue('btco'): return public.returnMsg(True, '您已安装过了.') return public.returnMsg(False, '安装失败')
def internalerror(e): #if str(e).find('Permanent Redirect') != -1: return e errorStr = public.ReadFile('./BTPanel/templates/' + public.GetConfigValue('template') + '/error.html') try: if not app.config['DEBUG']: errorStr = errorStr.format(public.getMsg('PAGE_ERR_500_TITLE'),public.getMsg('PAGE_ERR_500_H1'),public.getMsg('PAGE_ERR_500_P1'),public.getMsg('NAME'),public.getMsg('PAGE_ERR_HELP')) else: errorStr = errorStr.format(public.getMsg('PAGE_ERR_500_TITLE'),str(e),'<pre>'+public.get_error_info() + '</pre>','The above debugging information is only displayed in developer mode','Version: ' + public.version()) except IndexError:pass return errorStr,500
def internalerror(e): #if str(e).find('Permanent Redirect') != -1: return e public.submit_error() errorStr = public.ReadFile('./BTPanel/templates/' + public.GetConfigValue('template') + '/error.html') try: if not app.config['DEBUG']: errorStr = errorStr.format(public.getMsg('PAGE_ERR_500_TITLE'),public.getMsg('PAGE_ERR_500_H1'),public.getMsg('PAGE_ERR_500_P1'),public.getMsg('NAME'),public.getMsg('PAGE_ERR_HELP')) else: errorStr = errorStr.format(public.getMsg('PAGE_ERR_500_TITLE'),str(e),'<pre>'+public.get_error_info() + '</pre>','以上调试信息仅在开发者模式显示','版本号: ' + public.version()) except IndexError:pass return errorStr,500