def control_init(): time.sleep(1) sql = db.Sql().dbfile('system') if not sql.table('sqlite_master').where('type=? AND name=?', ('table', 'load_average')).count(): csql = '''CREATE TABLE IF NOT EXISTS `load_average` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `pro` REAL, `one` REAL, `five` REAL, `fifteen` REAL, `addtime` INTEGER )''' sql.execute(csql, ()) if not public.M('sqlite_master').where( 'type=? AND name=? AND sql LIKE ?', ('table', 'sites', '%type_id%')).count(): public.M('sites').execute( "alter TABLE sites add edate integer DEFAULT '0000-00-00'", ()) public.M('sites').execute( "alter TABLE sites add type_id integer DEFAULT 0", ()) sql = db.Sql() if not sql.table('sqlite_master').where('type=? AND name=?', ('table', 'site_types')).count(): csql = '''CREATE TABLE IF NOT EXISTS `site_types` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` REAL, `ps` REAL )''' sql.execute(csql, ()) if not sql.table('sqlite_master').where( 'type=? AND name=?', ('table', 'download_token')).count(): csql = '''CREATE TABLE IF NOT EXISTS `download_token` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `token` REAL, `filename` REAL, `total` INTEGER DEFAULT 0, `expire` INTEGER, `password` REAL, `ps` REAL, `addtime` INTEGER )''' sql.execute(csql, ()) if not sql.table('sqlite_master').where('type=? AND name=?', ('table', 'messages')).count(): csql = '''CREATE TABLE IF NOT EXISTS `messages` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `level` TEXT, `msg` TEXT, `state` INTEGER DEFAULT 0, `expire` INTEGER, `addtime` INTEGER )''' sql.execute(csql, ()) if not public.M('sqlite_master').where( 'type=? AND name=? AND sql LIKE ?', ('table', 'logs', '%username%')).count(): public.M('logs').execute( "alter TABLE logs add uid integer DEFAULT '1'", ()) public.M('logs').execute( "alter TABLE logs add username TEXT DEFAULT 'system'", ()) if not public.M('sqlite_master').where( 'type=? AND name=? AND sql LIKE ?', ('table', 'crontab', '%status%')).count(): public.M('crontab').execute( "ALTER TABLE 'crontab' ADD 'status' INTEGER DEFAULT 1", ()) public.M('crontab').execute( "ALTER TABLE 'crontab' ADD 'save' INTEGER DEFAULT 3", ()) public.M('crontab').execute( "ALTER TABLE 'crontab' ADD 'backupTo' TEXT DEFAULT off", ()) public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'sName' TEXT", ()) public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'sBody' TEXT", ()) public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'sType' TEXT", ()) public.M('crontab').execute( "ALTER TABLE 'crontab' ADD 'urladdress' TEXT", ()) public.M('users').where( 'email=? or email=?', ('*****@*****.**', '*****@*****.**')).setField( 'email', '*****@*****.**') filename = '/www/server/nginx/off' if os.path.exists(filename): os.remove(filename) c = public.to_string([ 99, 104, 97, 116, 116, 114, 32, 45, 105, 32, 47, 119, 119, 119, 47, 115, 101, 114, 118, 101, 114, 47, 112, 97, 110, 101, 108, 47, 99, 108, 97, 115, 115, 47, 42 ]) try: init_file = '/etc/init.d/bt' src_file = '/www/server/panel/init.sh' md51 = public.md5(init_file) md52 = public.md5(src_file) if md51 != md52: import shutil shutil.copyfile(src_file, init_file) if os.path.getsize(init_file) < 10: public.ExecShell("chattr -i " + init_file) public.ExecShell("\cp -arf %s %s" % (src_file, init_file)) public.ExecShell("chmod +x %s" % init_file) except: pass public.writeFile('/var/bt_setupPath.conf', '/www') public.ExecShell(c) p_file = 'class/plugin2.so' if os.path.exists(p_file): public.ExecShell("rm -f class/*.so") public.ExecShell( "chmod -R 600 /www/server/panel/data;chmod -R 600 /www/server/panel/config;chmod -R 700 /www/server/cron;chmod -R 600 /www/server/cron/*.log;chown -R root:root /www/server/panel/data;chown -R root:root /www/server/panel/config" ) #disable_putenv('putenv') clean_session() #set_crond() clean_max_log('/www/server/panel/plugin/rsync/lsyncd.log') clean_max_log('/root/.pm2/pm2.log', 1024 * 1024 * 20) remove_tty1() clean_hook_log() run_new() clean_max_log('/www/server/cron', 1024 * 1024 * 5, 20) #check_firewall() check_dnsapi() clean_php_log()
def get_pd(): tmp = -1 tmp1 = cache.get( public.to_string([ 112, 108, 117, 103, 105, 110, 95, 115, 111, 102, 116, 95, 108, 105, 115, 116 ])) if not tmp1: import panelPlugin tmp1 = panelPlugin.panelPlugin().get_cloud_list() if tmp1: tmp = tmp1[public.to_string([112, 114, 111])] else: tmp4 = cache.get(public.to_string([112, 95, 116, 111, 107, 101, 110])) if tmp4: tmp_f = public.to_string([47, 116, 109, 112, 47]) + tmp4 if not os.path.exists(tmp_f): public.writeFile(tmp_f, '-1') tmp = public.readFile(tmp_f) if tmp: tmp = int(tmp) tmp = 0 if tmp == -1: tmp3 = public.to_string([20813, 36153, 29256]) elif tmp == -2: tmp3 = public.to_string([ 60, 115, 112, 97, 110, 32, 99, 108, 97, 115, 115, 61, 34, 98, 116, 112, 114, 111, 45, 103, 114, 97, 121, 34, 62, 60, 115, 112, 97, 110, 32, 115, 116, 121, 108, 101, 61, 34, 99, 111, 108, 111, 114, 58, 32, 35, 102, 99, 54, 100, 50, 54, 59, 102, 111, 110, 116, 45, 119, 101, 105, 103, 104, 116, 58, 32, 98, 111, 108, 100, 59, 109, 97, 114, 103, 105, 110, 45, 114, 105, 103, 104, 116, 58, 53, 112, 120, 34, 62, 24050, 36807, 26399, 60, 47, 115, 112, 97, 110, 62, 60, 97, 32, 99, 108, 97, 115, 115, 61, 34, 98, 116, 108, 105, 110, 107, 34, 32, 111, 110, 99, 108, 105, 99, 107, 61, 34, 98, 116, 46, 115, 111, 102, 116, 46, 117, 112, 100, 97, 116, 97, 95, 112, 114, 111, 40, 41, 34, 62, 32493, 36153, 60, 47, 97, 62, 60, 47, 115, 112, 97, 110, 62 ]) elif tmp >= 0: if tmp == 0: tmp2 = public.to_string([27704, 20037, 25480, 26435]) tmp3 = public.to_string([ 60, 115, 112, 97, 110, 32, 99, 108, 97, 115, 115, 61, 34, 98, 116, 112, 114, 111, 34, 62, 123, 48, 125, 60, 115, 112, 97, 110, 32, 115, 116, 121, 108, 101, 61, 34, 99, 111, 108, 111, 114, 58, 32, 35, 102, 99, 54, 100, 50, 54, 59, 102, 111, 110, 116, 45, 119, 101, 105, 103, 104, 116, 58, 32, 98, 111, 108, 100, 59, 34, 62, 123, 49, 125, 60, 47, 115, 112, 97, 110, 62, 60, 47, 115, 112, 97, 110, 62 ]).format(public.to_string([21040, 26399, 26102, 38388, 65306]), tmp2) else: tmp2 = time.strftime( public.to_string([37, 89, 45, 37, 109, 45, 37, 100]), time.localtime(tmp)) tmp3 = public.to_string([ 60, 115, 112, 97, 110, 32, 99, 108, 97, 115, 115, 61, 34, 98, 116, 112, 114, 111, 34, 62, 21040, 26399, 26102, 38388, 65306, 60, 115, 112, 97, 110, 32, 115, 116, 121, 108, 101, 61, 34, 99, 111, 108, 111, 114, 58, 32, 35, 102, 99, 54, 100, 50, 54, 59, 102, 111, 110, 116, 45, 119, 101, 105, 103, 104, 116, 58, 32, 98, 111, 108, 100, 59, 109, 97, 114, 103, 105, 110, 45, 114, 105, 103, 104, 116, 58, 53, 112, 120, 34, 62, 123, 48, 125, 60, 47, 115, 112, 97, 110, 62, 60, 97, 32, 99, 108, 97, 115, 115, 61, 34, 98, 116, 108, 105, 110, 107, 34, 32, 111, 110, 99, 108, 105, 99, 107, 61, 34, 98, 116, 46, 115, 111, 102, 116, 46, 117, 112, 100, 97, 116, 97, 95, 112, 114, 111, 40, 41, 34, 62, 32493, 36153, 60, 47, 97, 62, 60, 47, 115, 112, 97, 110, 62 ]).format(tmp2) else: tmp3 = public.to_string([20813, 36153, 29256]) return tmp3
def panel_other(name=None,fun = None,stype=None): if not name: name = 'coll' if not public.path_safe_check("%s/%s/%s" % (name,fun,stype)): return abort(404) if name.find('./') != -1 or not re.match("^[\w-]+$",name): return abort(404) if not name: return public.returnJson(False,public.GetMsg("PLUGIN_INPUT_A")),json_header p_path = '/www/server/panel/plugin/' + name if not os.path.exists(p_path): return abort(404) #是否响插件应静态文件 if fun == 'static': if stype.find('./') != -1 or not os.path.exists(p_path + '/static'): return abort(404) s_file = p_path + '/static/' + stype if s_file.find('..') != -1: return abort(404) if not re.match("^[\w\./-]+$",s_file): return abort(404) if not public.path_safe_check(s_file): return abort(404) if not os.path.exists(s_file): return abort(404) return send_file(s_file,conditional=True,add_etags=True) #准备参数 args = get_input(); args.client_ip = public.GetClientIp(); if not fun: fun = 'index.html' if not stype: tmp = fun.split('.') fun = tmp[0] if len(tmp) == 1: tmp.append('') stype = tmp[1] args.fun = fun #初始化插件对象 try: is_php = os.path.exists(p_path + '/index.php') if not is_php: sys.path.append(p_path); plugin_main = __import__(name+'_main') try: if sys.version_info[0] == 2: reload(plugin_main) else: from imp import reload reload(plugin_main) except:pass plu = eval('plugin_main.' + name + '_main()') if not hasattr(plu,fun): return public.returnJson(False,'SPECIFY_METHOD'),json_header #检查访问权限 comReturn = comm.local() if comReturn: if not is_php: 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 if r_type != bool or not checks: return public.getJson(checks),json_header #初始化面板数据 comm.setSession() comm.init() comm.checkWebType() comm.GetOS() import panelPlugin plugins = panelPlugin.panelPlugin() args.name = name if not plugins.check_accept(args): return public.returnMsg(False,public.to_string([24744, 26410, 36141, 20080, 91, 37, 115, 93, 25110, 25480, 26435, 24050, 21040, 26399, 33]) % (plugins.get_title_byname(args),)) #执行插件方法 if not is_php: data = eval('plu.'+fun+'(args)') else: import panelPHP args.s = fun args.name = name data = panelPHP.panelPHP(name).exec_php_script(args) r_type = type(data) if r_type == Response: return data #处理响应 if stype == 'json': #响应JSON return public.getJson(data),json_header elif stype == 'html': #使用模板 t_path_root = p_path + '/templates/' t_path = t_path_root + fun + '.html' if not os.path.exists(t_path): return public.returnJson(False,public.GetMsg("SPECIFY_TEMPLATE")), json_header t_body = public.readFile(t_path) #处理模板包含 rep = '{%\s?include\s"(.+)"\s?%}' includes = re.findall(rep,t_body) for i_file in includes: filename = p_path + '/templates/' + i_file i_body = 'ERROR: File '+filename+' does not exists.' if os.path.exists(filename): i_body = public.readFile(filename) t_body = re.sub(rep.replace('(.+)',i_file),i_body,t_body) return render_template_string(t_body,data = data) else: #直接响应插件返回值,可以是任意flask支持的响应类型 r_type = type(data) if r_type == dict: return public.returnJson(False,public.GetMsg("RETURN_TYPE_ERR") + '[%s]' % r_type), json_header return data except: error_info = public.get_error_info() public.submit_error(error_info) return error_info.replace('\n','<br>\n')
def control_init(): global exec_tips if exec_tips: return exec_tips = True sql_tips = '/dev/shm/bt_sql_tips.pl' if not os.path.exists(sql_tips): sql = db.Sql().dbfile('system') csql = '''CREATE TABLE IF NOT EXISTS `load_average` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `pro` REAL, `one` REAL, `five` REAL, `fifteen` REAL, `addtime` INTEGER )''' sql.execute(csql, ()) public.M('sites').execute( "alter TABLE sites add edate integer DEFAULT '0000-00-00'", ()) public.M('sites').execute( "alter TABLE sites add type_id integer DEFAULT 0", ()) sql = db.Sql() csql = '''CREATE TABLE IF NOT EXISTS `site_types` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` REAL, `ps` REAL )''' sql.execute(csql, ()) public.writeFile(sql_tips, 'True') filename = '/www/server/nginx/off' if os.path.exists(filename): os.remove(filename) c = public.to_string([ 99, 104, 97, 116, 116, 114, 32, 45, 105, 32, 47, 119, 119, 119, 47, 115, 101, 114, 118, 101, 114, 47, 112, 97, 110, 101, 108, 47, 99, 108, 97, 115, 115, 47, 42 ]) try: init_file = '/etc/init.d/bt' src_file = '/www/server/panel/init.sh' md51 = public.md5(init_file) md52 = public.md5(src_file) if md51 != md52: import shutil shutil.copyfile(src_file, init_file) if os.path.getsize(init_file) < 10: os.system("chattr -i " + init_file) os.system("\cp -arf %s %s" % (src_file, init_file)) os.system("chmod +x %s" % init_file) except: pass public.writeFile('/var/bt_setupPath.conf', '/www') public.ExecShell(c) p_file = 'class/plugin2.so' if os.path.exists(p_file): public.ExecShell("rm -f class/*.so") public.ExecShell( "chmod -R 600 /www/server/panel/data;chmod -R 600 /www/server/panel/config;chmod -R 700 /www/server/cron;chmod -R 600 /www/server/cron/*.log;chown -R root:root /www/server/panel/data;chown -R root:root /www/server/panel/config" ) #disable_putenv('putenv') clean_session() #set_crond() clean_max_log('/www/server/panel/plugin/rsync/lsyncd.log') remove_tty1() clean_hook_log()
def panel_other(name=None,fun = None,stype=None): #插件公共动态路由 <name: 插件名称, fun: 被访问的插件方法名, stype:fun=static时则为文件相对于插件static目录下的路径> 访问方式:http://面板地址:端口/插件名称/插件方法.响应类型(html|json) ''' 插件静态文件存储目录: static (允许多级目录,请不要将重要文件放在静态目录),访问方式:http://面板地址:端口/插件名称/static/相对于static的文件路径 如:http://demo.cn:8888/demo/static/js/test.js 插件模板文件存储目录: templates (请不要在里面创建二级目录) 使用模板方法: http://demo.cn:8888/demo/get_logs.html 插件模板文件格式:方法名.html (支持jinja2语法,但无法使用extends语句),请在被访问的方法中返回一个dict,它将被当作data参数传入到模板变量 响应JSON数据: 示例: http://demo.cn:8888/demo/get_logs.json 注意:此处会将插件方法中返回的数据自动转换成JSON字符串响应 直接响应: 示例:http://demo.cn:8888/demo/get_logs ,此时直接响应插件方法返回的数据,注意: 支持 int、float、string、list、redirect对象 ''' #前置准备 if not name: name = 'coll' if not public.path_safe_check("%s/%s/%s" % (name,fun,stype)): return abort(404) #是否响应面板默认静态文件 if name == 'static': s_file = '/www/server/panel/BTPanel/static/' + fun + '/' + stype if s_file.find('..') != -1 or s_file.find('./') != -1: return abort(404) if not os.path.exists(s_file): return abort(404) return send_file(s_file,conditional=True,add_etags=True) if name.find('./') != -1 or not re.match("^[\w-]+$",name): return public.returnJson(False,public.GetMsg("REQUEST_ERR")),json_header if not name: return public.returnJson(False,public.GetMsg("PLUGIN_INPUT_A")),json_header p_path = '/www/server/panel/plugin/' + name if not os.path.exists(p_path): return abort(404) #是否响插件应静态文件 if fun == 'static': if stype.find('./') != -1 or not os.path.exists(p_path + '/static'): return public.returnJson(False,public.GetMsg("REQUEST_ERR")),json_header s_file = p_path + '/static/' + stype if s_file.find('..') != -1: return abort(404) if not os.path.exists(s_file): return public.returnJson(False,'The specified file does not exist ['+stype+']'),json_header return send_file(s_file,conditional=True,add_etags=True) #准备参数 args = get_input(); args.client_ip = public.GetClientIp(); if not fun: fun = 'index.html' if not stype: tmp = fun.split('.') fun = tmp[0] if len(tmp) == 1: tmp.append('') stype = tmp[1] args.fun = fun #初始化插件对象 try: sys.path.append(p_path); plugin_main = __import__(name+'_main') try: if sys.version_info[0] == 2: reload(plugin_main) else: from imp import reload reload(plugin_main) except:pass plu = eval('plugin_main.' + name + '_main()') if not hasattr(plu, fun): return public.returnJson(False, public.GetMsg("SPECIFY_METHOD")), json_header #检查访问权限 comReturn = comm.local() if comReturn: if not hasattr(plu, '_check'): return public.returnJson(False, public.GetMsg("SPECIFY_PLUG_ERR")), json_header checks = plu._check(args) r_type = type(checks) if r_type == Response: return checks if r_type != bool or not checks: return public.getJson(checks),json_header #初始化面板数据 comm.setSession() comm.init() comm.checkWebType() comm.GetOS() import panelPlugin plugins = panelPlugin.panelPlugin() args.name = name if not plugins.check_accept(args): return public.returnMsg(False,public.to_string([24744, 26410, 36141, 20080, 91, 37, 115, 93, 25110, 25480, 26435, 24050, 21040, 26399, 33]) % (plugins.get_title_byname(args),)) #执行插件方法 data = eval('plu.'+fun+'(args)') r_type = type(data) if r_type == Response: return data #处理响应 if stype == 'json': #响应JSON return public.getJson(data),json_header elif stype == 'html': #使用模板 t_path_root = p_path + '/templates/' t_path = t_path_root + fun + '.html' if not os.path.exists(t_path): return public.returnJson(False,public.GetMsg("SPECIFY_TEMPLATE")), json_header t_body = public.readFile(t_path) #处理模板包含 rep = '{%\s?include\s"(.+)"\s?%}' includes = re.findall(rep,t_body) for i_file in includes: filename = p_path + '/templates/' + i_file i_body = 'ERROR: File '+filename+' does not exists.' if os.path.exists(filename): i_body = public.readFile(filename) t_body = re.sub(rep.replace('(.+)',i_file),i_body,t_body) return render_template_string(t_body,data = data) else: #直接响应插件返回值,可以是任意flask支持的响应类型 r_type = type(data) if r_type == dict: return public.returnJson(False,public.GetMsg("RETURN_TYPE_ERR") + '[%s]' % r_type), json_header return data except: return public.get_error_info().replace('\n','<br>\n')
def control_init(): dirPath = '/www/server/phpmyadmin/pma' if os.path.exists(dirPath): public.ExecShell("rm -rf {}".format(dirPath)) dirPath = '/www/server/adminer' if os.path.exists(dirPath): public.ExecShell("rm -rf {}".format(dirPath)) dirPath = '/www/server/panel/adminer' if os.path.exists(dirPath): public.ExecShell("rm -rf {}".format(dirPath)) time.sleep(1) sql = db.Sql().dbfile('system') if not sql.table('sqlite_master').where('type=? AND name=?', ('table', 'load_average')).count(): csql = '''CREATE TABLE IF NOT EXISTS `load_average` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `pro` REAL, `one` REAL, `five` REAL, `fifteen` REAL, `addtime` INTEGER )''' sql.execute(csql,()) if not public.M('sqlite_master').where('type=? AND name=? AND sql LIKE ?', ('table', 'sites','%type_id%')).count(): public.M('sites').execute("alter TABLE sites add type_id integer DEFAULT 0",()) if not public.M('sqlite_master').where('type=? AND name=? AND sql LIKE ?', ('table', 'sites','%edate%')).count(): public.M('sites').execute("alter TABLE sites add edate integer DEFAULT '0000-00-00'",()) if not public.M('sqlite_master').where('type=? AND name=? AND sql LIKE ?', ('table', 'sites','%project_type%')).count(): public.M('sites').execute("alter TABLE sites add project_type STRING DEFAULT 'PHP'",()) if not public.M('sqlite_master').where('type=? AND name=? AND sql LIKE ?', ('table', 'sites','%project_config%')).count(): public.M('sites').execute("alter TABLE sites add project_config STRING DEFAULT '{}'",()) sql = db.Sql() if not sql.table('sqlite_master').where('type=? AND name=?', ('table', 'site_types')).count(): csql = '''CREATE TABLE IF NOT EXISTS `site_types` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` REAL, `ps` REAL )''' sql.execute(csql,()) if not sql.table('sqlite_master').where('type=? AND name=?', ('table', 'download_token')).count(): csql = '''CREATE TABLE IF NOT EXISTS `download_token` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `token` REAL, `filename` REAL, `total` INTEGER DEFAULT 0, `expire` INTEGER, `password` REAL, `ps` REAL, `addtime` INTEGER )''' sql.execute(csql,()) if not sql.table('sqlite_master').where('type=? AND name=?', ('table', 'messages')).count(): csql = '''CREATE TABLE IF NOT EXISTS `messages` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `level` TEXT, `msg` TEXT, `state` INTEGER DEFAULT 0, `expire` INTEGER, `addtime` INTEGER )''' sql.execute(csql,()) if not sql.table('sqlite_master').where('type=? AND name=?', ('table', 'temp_login')).count(): csql = '''CREATE TABLE IF NOT EXISTS `temp_login` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `token` REAL, `salt` REAL, `state` INTEGER, `login_time` INTEGER, `login_addr` REAL, `logout_time` INTEGER, `expire` INTEGER, `addtime` INTEGER )''' sql.execute(csql,()) if not public.M('sqlite_master').where('type=? AND name=? AND sql LIKE ?', ('table', 'logs','%username%')).count(): public.M('logs').execute("alter TABLE logs add uid integer DEFAULT '1'",()) public.M('logs').execute("alter TABLE logs add username TEXT DEFAULT 'system'",()) if not public.M('sqlite_master').where('type=? AND name=? AND sql LIKE ?', ('table', 'crontab','%status%')).count(): public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'status' INTEGER DEFAULT 1",()) public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'save' INTEGER DEFAULT 3",()) public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'backupTo' TEXT DEFAULT off",()) public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'sName' TEXT",()) public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'sBody' TEXT",()) public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'sType' TEXT",()) public.M('crontab').execute("ALTER TABLE 'crontab' ADD 'urladdress' TEXT",()) public.M('users').where('email=? or email=?',('*****@*****.**','*****@*****.**')).setField('email','*****@*****.**') if not public.M('sqlite_master').where('type=? AND name=? AND sql LIKE ?', ('table', 'users','%salt%')).count(): public.M('users').execute("ALTER TABLE 'users' ADD 'salt' TEXT",()) public.chdck_salt() filename = '/www/server/nginx/off' if os.path.exists(filename): os.remove(filename) c = public.to_string([99, 104, 97, 116, 116, 114, 32, 45, 105, 32, 47, 119, 119, 119, 47, 115, 101, 114, 118, 101, 114, 47, 112, 97, 110, 101, 108, 47, 99, 108, 97, 115, 115, 47, 42]) try: init_file = '/etc/init.d/bt' src_file = '/www/server/panel/init.sh' md51 = public.md5(init_file) md52 = public.md5(src_file) if md51 != md52: import shutil shutil.copyfile(src_file,init_file) if os.path.getsize(init_file) < 10: public.ExecShell("chattr -i " + init_file) public.ExecShell("\cp -arf %s %s" % (src_file,init_file)) public.ExecShell("chmod +x %s" % init_file) except:pass public.writeFile('/var/bt_setupPath.conf','/www') public.ExecShell(c) p_file = 'class/plugin2.so' if os.path.exists(p_file): public.ExecShell("rm -f class/*.so") public.ExecShell("chmod -R 600 /www/server/panel/data;chmod -R 600 /www/server/panel/config;chmod -R 700 /www/server/cron;chmod -R 600 /www/server/cron/*.log;chown -R root:root /www/server/panel/data;chown -R root:root /www/server/panel/config;chown -R root:root /www/server/phpmyadmin;chmod -R 755 /www/server/phpmyadmin") if os.path.exists("/www/server/mysql"): public.ExecShell("chown mysql:mysql /etc/my.cnf;chmod 600 /etc/my.cnf") public.ExecShell("rm -rf /www/server/panel/temp/*") if not public.is_debug(): public.ExecShell("rm -f /www/server/panel/class/pluginAuth.py") stop_path = '/www/server/stop' if not os.path.exists(stop_path): os.makedirs(stop_path) public.ExecShell("chown -R root:root {path};chmod -R 755 {path}".format(path=stop_path)) public.ExecShell('chmod 755 /www;chmod 755 /www/server') if os.path.exists('/www/server/phpmyadmin/pma'): public.ExecShell("rm -rf /www/server/phpmyadmin/pma") if os.path.exists("/www/server/adminer"): public.ExecShell("rm -rf /www/server/adminer") if os.path.exists("/www/server/panel/adminer"): public.ExecShell("rm -rf /www/server/panel/adminer") if os.path.exists('/dev/shm/session.db'): os.remove('/dev/shm/session.db') #disable_putenv('putenv') #clean_session() #set_crond() test_ping() clean_max_log('/www/server/panel/plugin/rsync/lsyncd.log') clean_max_log('/var/log/rsyncd.log',1024*1024*10) clean_max_log('/root/.pm2/pm2.log',1024*1024*20) remove_tty1() clean_hook_log() run_new() clean_max_log('/www/server/cron',1024*1024*5,20) #check_firewall() check_dnsapi() clean_php_log() files_set_mode() set_pma_access() # public.set_open_basedir() clear_fastcgi_safe() update_py37() run_script() set_php_cli_env()