def setPathInfo(self,get): #设置PATH_INFO version = get.version type = get.type if public.get_webserver() == 'nginx': path = web.ctx.session.setupPath+'/nginx/conf/enable-php-'+version+'.conf'; conf = public.readFile(path); rep = "\s+#*include\s+pathinfo.conf;"; if type == 'on': conf = re.sub(rep,'\n\t\t\tinclude pathinfo.conf;',conf) else: conf = re.sub(rep,'\n\t\t\t#include pathinfo.conf;',conf) public.writeFile(path,conf) public.serviceReload(); path = web.ctx.session.setupPath+'/php/'+version+'/etc/php.ini'; conf = public.readFile(path); rep = "\n*\s*cgi\.fix_pathinfo\s*=\s*([0-9]+)\s*\n"; status = '0' if type == 'on':status = '1' conf = re.sub(rep,"\ncgi.fix_pathinfo = "+status+"\n",conf) public.writeFile(path,conf) public.WriteLog("TYPE_PHP", "PHP_PATHINFO_SUCCESS",(version,type)); public.phpReload(version); return public.returnMsg(True,'SET_SUCCESS');
def GetSSLInfo(self,get): self.__PDATA['data']['partnerOrderId'] = get.partnerOrderId; self.__PDATA['data'] = self.De_Code(self.__PDATA['data']); result = json.loads(public.httpPost(self.__APIURL + '/GetSSLInfo',self.__PDATA)); result['data'] = self.En_Code(result['data']); #写配置到站点 if hasattr(get,'siteName'): try: siteName = get.siteName; path = '/etc/letsencrypt/live/'+ siteName; if not os.path.exists(path): public.ExecShell('mkdir -p ' + path) csrpath = path+"/fullchain.pem"; keypath = path+"/privkey.pem"; pidpath = path+"/partnerOrderId"; #清理旧的证书链 public.ExecShell('rm -f ' + keypath) public.ExecShell('rm -f ' + csrpath) public.ExecShell('rm -rf ' + path + '-00*') public.ExecShell('rm -rf /etc/letsencrypt/archive/' + get.siteName) public.ExecShell('rm -rf /etc/letsencrypt/archive/' + get.siteName + '-00*') public.ExecShell('rm -f /etc/letsencrypt/renewal/'+ get.siteName + '.conf') public.ExecShell('rm -f /etc/letsencrypt/renewal/'+ get.siteName + '-00*.conf') public.ExecShell('rm -f ' + path + '/README'); public.writeFile(keypath,result['data']['privateKey']); public.writeFile(csrpath,result['data']['cert']+result['data']['certCa']); public.writeFile(pidpath,get.partnerOrderId); import panelSite panelSite.panelSite().SetSSLConf(get); public.serviceReload(); return public.returnMsg(True,'SET_SUCCESS'); except Exception,ex: return public.returnMsg(False,'SET_ERROR,' + str(ex));
def ClearOther(): clearPath = [ {'path':'/www/server/panel','find':'testDisk_'}, {'path':'/www/wwwlogs','find':'log'}, {'path':'/tmp','find':'panelBoot.pl'}, {'path':'/www/server/panel/install','find':'.rpm'} ] total = count = 0; print '|-正在清理临时文件及网站日志 ...'; for c in clearPath: for d in os.listdir(c['path']): if d.find(c['find']) == -1: continue; filename = c['path'] + '/' + d; fsize = os.path.getsize(filename); print '|---['+ToSize(fsize)+'] del ' + filename, total += fsize if os.path.isdir(filename): shutil.rmtree(filename) else: os.remove(filename) print '\t\033[1;32m[OK]\033[0m' count += 1; public.serviceReload(); os.system('/etc/init.d/bt restart > /dev/null'); print '|-已完成临时文件及网站日志的清理,删除['+str(count)+']个文件,共释放磁盘空间['+ToSize(total)+']'; return total,count
def setPHPMaxSize(self,get): version = get.version max = get.max if int(max) < 2: return public.returnMsg(False,'PHP_UPLOAD_MAX_ERR') #设置PHP path = web.ctx.session.setupPath+'/php/'+version+'/etc/php.ini' conf = public.readFile(path) rep = u"\nupload_max_filesize\s*=\s*[0-9]+M" conf = re.sub(rep,u'\nupload_max_filesize = '+max+'M',conf) rep = u"\npost_max_size\s*=\s*[0-9]+M" conf = re.sub(rep,u'\npost_max_size = '+max+'M',conf) public.writeFile(path,conf) if public.get_webserver() == 'nginx': #设置Nginx path = web.ctx.session.setupPath+'/nginx/conf/nginx.conf' conf = public.readFile(path) rep = "client_max_body_size\s+([0-9]+)m" tmp = re.search(rep,conf).groups() if int(tmp[0]) < int(max): conf = re.sub(rep,'client_max_body_size '+max+'m',conf) public.writeFile(path,conf) public.serviceReload() public.phpReload(version); public.WriteLog("TYPE_PHP", "PHP_UPLOAD_MAX",(version,max)) return public.returnMsg(True,'SET_SUCCESS')
def CheckStatusConf(self): if public.get_webserver() != 'nginx': return; filename = web.ctx.session.setupPath + '/panel/vhost/nginx/phpfpm_status.conf'; if os.path.exists(filename): return; conf = '''server { listen 80; server_name 127.0.0.1; allow 127.0.0.1; location /nginx_status { stub_status on; access_log off; } location /phpfpm_52_status { fastcgi_pass unix:/tmp/php-cgi-52.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_53_status { fastcgi_pass unix:/tmp/php-cgi-53.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_54_status { fastcgi_pass unix:/tmp/php-cgi-54.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_55_status { fastcgi_pass unix:/tmp/php-cgi-55.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_56_status { fastcgi_pass unix:/tmp/php-cgi-56.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_70_status { fastcgi_pass unix:/tmp/php-cgi-70.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_71_status { fastcgi_pass unix:/tmp/php-cgi-71.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_72_status { fastcgi_pass unix:/tmp/php-cgi-72.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } }''' public.writeFile(filename,conf); public.serviceReload();
def CheckPHPINFO(self): php_versions = ['52','53','54','55','56','70','71','72']; path = web.ctx.session.setupPath + '/panel/vhost/nginx/phpinfo.conf'; if not os.path.exists(path): opt = ""; for version in php_versions: opt += "\n\tlocation /"+version+" {\n\t\tinclude enable-php-"+version+".conf;\n\t}"; phpinfoBody = '''server { listen 80; server_name 127.0.0.2; allow 127.0.0.1; index phpinfo.php index.html index.php; root /www/server/phpinfo; %s }''' % (opt,); public.writeFile(path,phpinfoBody); path = web.ctx.session.setupPath + '/panel/vhost/apache/phpinfo.conf'; if not os.path.exists(path): opt = ""; for version in php_versions: opt += """\n<Location /%s> SetHandler "proxy:unix:/tmp/php-cgi-%s.sock|fcgi://localhost" </Location>""" % (version,version); try: apacheVersion = public.readFile('/www/server/apache/version.pl').strip(); if apacheVersion == '2.2': opt = ""; except: pass; phpinfoBody = ''' <VirtualHost *:80> DocumentRoot "/www/server/phpinfo" ServerAdmin phpinfo ServerName 127.0.0.2 %s <Directory "/www/server/phpinfo"> SetOutputFilter DEFLATE Options FollowSymLinks AllowOverride All Order allow,deny Allow from all DirectoryIndex index.php index.html index.htm default.php default.html default.htm </Directory> </VirtualHost> ''' % (opt,); public.writeFile(path,phpinfoBody); public.serviceReload();
def ClearOther(): clearPath = [{ 'path': '/www/server/panel', 'find': 'testDisk_' }, { 'path': '/www/wwwlogs', 'find': 'log' }, { 'path': '/tmp', 'find': 'panelBoot.pl' }, { 'path': '/www/server/panel/install', 'find': '.rpm' }, { 'path': '/www/server/panel/install', 'find': '.zip' }, { 'path': '/www/server/panel/install', 'find': '.gz' }] total = count = 0 print(public.GetMsg('CLEAR_RUBBISH3')) for c in clearPath: for d in os.listdir(c['path']): if d.find(c['find']) == -1: continue filename = c['path'] + '/' + d fsize = os.path.getsize(filename) print('|---[' + ToSize(fsize) + '] del ' + filename), total += fsize if os.path.isdir(filename): shutil.rmtree(filename) else: os.remove(filename) print('\t\033[1;32m[OK]\033[0m') count += 1 public.serviceReload() os.system('sleep 1 && /etc/init.d/bt reload > /dev/null &') print(public.GetMsg("CLEAR_RUBBISH4", (str(count), ToSize(total)))) return total, count
def setPHPMaxTime(self, get): time = get.time version = get.version if int(time) < 30 or int(time) > 86400: return public.returnMsg(False, 'PHP_TIMEOUT_ERR') file = public.GetConfigValue( 'setup_path') + '/php/' + version + '/etc/php-fpm.conf' conf = public.readFile(file) rep = "request_terminate_timeout\s*=\s*([0-9]+)\n" conf = re.sub(rep, "request_terminate_timeout = " + time + "\n", conf) public.writeFile(file, conf) file = '/www/server/php/' + version + '/etc/php.ini' phpini = public.readFile(file) rep = "max_execution_time\s*=\s*([0-9]+)\r?\n" phpini = re.sub(rep, "max_execution_time = " + time + "\n", phpini) rep = "max_input_time\s*=\s*([0-9]+)\r?\n" phpini = re.sub(rep, "max_input_time = " + time + "\n", phpini) public.writeFile(file, phpini) if public.get_webserver() == 'nginx': #设置Nginx path = public.GetConfigValue( 'setup_path') + '/nginx/conf/nginx.conf' conf = public.readFile(path) rep = "fastcgi_connect_timeout\s+([0-9]+);" tmp = re.search(rep, conf).groups() if int(tmp[0]) < int(time): conf = re.sub(rep, 'fastcgi_connect_timeout ' + time + ';', conf) rep = "fastcgi_send_timeout\s+([0-9]+);" conf = re.sub(rep, 'fastcgi_send_timeout ' + time + ';', conf) rep = "fastcgi_read_timeout\s+([0-9]+);" conf = re.sub(rep, 'fastcgi_read_timeout ' + time + ';', conf) public.writeFile(path, conf) public.WriteLog("TYPE_PHP", "PHP_TIMEOUT", (version, time)) public.serviceReload() public.phpReload(version) return public.returnMsg(True, 'SET_SUCCESS')
def CreateRedirect(self, get): if self.__CheckRedirectStart(get, "create"): return self.__CheckRedirectStart(get, "create") redirectconf = self.__read_config(self.__redirectfile) redirectconf.append({ "sitename": get.sitename, "redirectname": get.redirectname, "tourl": get.tourl, "redirectdomain": json.loads(get.redirectdomain), "redirectpath": get.redirectpath, "redirecttype": get.redirecttype, "type": int(get.type), "domainorpath": get.domainorpath, "holdpath": int(get.holdpath) }) self.__write_config(self.__redirectfile, redirectconf) self.SetRedirectNginx(get) self.SetRedirectApache(get.sitename) self.SetRedirect(get) public.serviceReload() return public.returnMsg(True, 'CREATE_SUCCESS')
def SetWafConf(self,get): path = self.__WafConfigPath + '/' + get.name; if not os.path.exists(path): return public.returnMsg(False,"WAF_CONF_NOT_EXISTS"); data = public.readFile(path).split("\n") if get.act == "del": if not get.value in data: return public.returnMsg(False,"WAF_CONF_NOT_EXISTS"); tmp = [] for t in data: if get.value == t: continue; tmp.append(t); data = tmp; else: if get.value in data: return public.returnMsg(False,"WAF_CONF_EXISTS"); data.append(get.value); conf = "" for v in data: conf += v + "\n"; public.writeFile(path,conf[:-1]); public.serviceReload(); return public.returnMsg(True,"SUCCESS");
def ClearOther(): clearPath = [{ 'path': '/www/server/panel', 'find': 'testDisk_' }, { 'path': '/www/wwwlogs', 'find': 'log' }, { 'path': '/tmp', 'find': 'panelBoot.pl' }, { 'path': '/www/server/panel/install', 'find': '.rpm' }, { 'path': '/www/server/panel/install', 'find': '.zip' }, { 'path': '/www/server/panel/install', 'find': '.gz' }] total = count = 0 print('|-正在清理临时文件及网站日志 ...') for c in clearPath: for d in os.listdir(c['path']): if d.find(c['find']) == -1: continue filename = c['path'] + '/' + d if os.path.isdir(filename): continue fsize = os.path.getsize(filename) print('|---[' + ToSize(fsize) + '] del ' + filename), total += fsize os.remove(filename) print('\t\033[1;32m[OK]\033[0m') count += 1 public.serviceReload() os.system('sleep 1 && /etc/init.d/bt reload > /dev/null &') print('|-已完成临时文件及网站日志的清理,删除[' + str(count) + ']个文件,共释放磁盘空间[' + ToSize(total) + ']') return total, count
def DeleteRedirect(self, get): redirectconf = self.__read_config(self.__redirectfile) sitename = get.sitename redirectname = get.redirectname for i in range(len(redirectconf)): if redirectconf[i]["sitename"] == sitename and redirectconf[i][ "redirectname"] == redirectname: proxyname_md5 = self.__calc_md5( redirectconf[i]["redirectname"]) os.system("rm -f %s/panel/vhost/nginx/redirect/%s/%s_%s.conf" % (self.setupPath, redirectconf[i]["sitename"], proxyname_md5, redirectconf[i]["sitename"])) os.system( "rm -f %s/panel/vhost/apache/redirect/%s/%s_%s.conf" % (self.setupPath, redirectconf[i]["sitename"], proxyname_md5, redirectconf[i]["sitename"])) del redirectconf[i] self.__write_config(self.__redirectfile, redirectconf) self.SetRedirectNginx(get) self.SetRedirectApache(get.sitename) public.serviceReload() return public.returnMsg(True, 'DEL_SUCCESS')
def SetConfigList(self,get): conf = public.readFile(self.__ConfigFile); rep = get.name + "\s*=\s*(.+)\n"; keyList = json.loads(re.search(rep,conf).groups()[0].replace("{","[").replace("}","]")); if get.name != 'black_fileExt': rep2 = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"; if not re.search(rep2,get.value): return public.returnMsg(False,"WAF_CONF_ERR"); if get.act == 'del': if not get.value in keyList: return public.returnMsg(False,"WAF_CONF_NOT_EXISTS"); tmp = [] for t in keyList: if t == get.value: continue; tmp.append(t); keyList = tmp; else: if get.value in keyList:return public.returnMsg(False,"WAF_CONF_EXISTS"); keyList.append(get.value.strip()); keyStr = json.dumps(keyList).replace("[","{").replace("]","}"); conf = re.sub(rep,get.name + "=" + keyStr + "\n",conf); public.writeFile(self.__ConfigFile,conf); public.serviceReload(); return public.returnMsg(True,"SUCCESS");
def GetSSLInfo(self,get): self.__PDATA['data']['partnerOrderId'] = get.partnerOrderId self.__PDATA['data'] = self.De_Code(self.__PDATA['data']) time.sleep(3) result = json.loads(public.httpPost(self.__APIURL + '/GetSSLInfo',self.__PDATA)) result['data'] = self.En_Code(result['data']) if not 'privateKey' in result['data']: return result #写配置到站点 if hasattr(get,'siteName'): try: siteName = get.siteName path = '/www/server/panel/vhost/cert/' + siteName if not os.path.exists(path): public.ExecShell('mkdir -p ' + path) csrpath = path+"/fullchain.pem" keypath = path+"/privkey.pem" pidpath = path+"/partnerOrderId" #清理旧的证书链 public.ExecShell('rm -f ' + keypath) public.ExecShell('rm -f ' + csrpath) public.ExecShell('rm -rf ' + path + '-00*') public.ExecShell('rm -rf /etc/letsencrypt/archive/' + get.siteName) public.ExecShell('rm -rf /etc/letsencrypt/archive/' + get.siteName + '-00*') public.ExecShell('rm -f /etc/letsencrypt/renewal/'+ get.siteName + '.conf') public.ExecShell('rm -f /etc/letsencrypt/renewal/'+ get.siteName + '-00*.conf') public.ExecShell('rm -f ' + path + '/README') public.writeFile(keypath,result['data']['privateKey']) public.writeFile(csrpath,result['data']['cert']+result['data']['certCa']) public.writeFile(pidpath,get.partnerOrderId) import panelSite panelSite.panelSite().SetSSLConf(get) public.serviceReload() return public.returnMsg(True,'SET_SUCCESS') except: return public.returnMsg(False,'SET_ERROR') result['data'] = self.En_Code(result['data']) return result
def SetNginxValue(self, get): ngconfcontent = public.readFile(self.nginxconf) proxycontent = public.readFile(self.proxyfile) if public.get_webserver() == 'nginx': shutil.copyfile(self.nginxconf, '/tmp/ng_file_bk.conf') shutil.copyfile(self.proxyfile, '/tmp/proxyfile_bk.conf') conflist = [] getdict = get.__dict__ for i in getdict.keys(): if i != "__module__" and i != "__doc__" and i != "data" and i != "args" and i != "action": getpost = {"name": i, "value": str(getdict[i])} conflist.append(getpost) for c in conflist: rep = "%s\s+[^kKmMgG\;\n]+" % c["name"] if c["name"] == "worker_processes" or c["name"] == "gzip": if not re.search("auto|on|off|\d+", c["value"]): return public.returnMsg(False, 'INIT_ARGS_ERR') else: if not re.search("\d+", c["value"]): return public.returnMsg(False, 'INIT_ARGS_ERR') if re.search(rep, ngconfcontent): newconf = "%s %s" % (c["name"], c["value"]) ngconfcontent = re.sub(rep, newconf, ngconfcontent) elif re.search(rep, proxycontent): newconf = "%s %s" % (c["name"], c["value"]) proxycontent = re.sub(rep, newconf, proxycontent) public.writeFile(self.nginxconf, ngconfcontent) public.writeFile(self.proxyfile, proxycontent) isError = public.checkWebConfig() if (isError != True): shutil.copyfile('/tmp/ng_file_bk.conf', self.nginxconf) shutil.copyfile('/tmp/proxyfile_bk.conf', self.proxyfile) return public.returnMsg( False, 'ERROR: <br><a style="color:red;">' + isError.replace("\n", '<br>') + '</a>') public.serviceReload() return public.returnMsg(True, 'SET_SUCCESS')
def SaveFileBody(self,get): get.path = get.path.encode('utf-8'); if not os.path.exists(get.path): if get.path.find('.htaccess') == -1: return public.returnMsg(False,'FILE_NOT_EXISTS') try: isConf = -1 if os.path.exists('/etc/init.d/nginx') or os.path.exists('/etc/init.d/httpd'): isConf = get.path.find('nginx'); if isConf == -1: isConf = get.path.find('apache'); if isConf == -1: isConf = get.path.find('rewrite'); if isConf != -1: os.system('\\cp -a '+get.path+' /tmp/backup.conf'); data = get.data[0]; if get.path.find('/www/server/cron') != -1: try: import crontab data = crontab.crontab().CheckScript(data); except: pass if get.encoding == 'ascii':get.encoding = 'utf-8'; public.writeFile(get.path,data.encode(get.encoding)); if isConf != -1: isError = public.checkWebConfig(); if isError != True: os.system('\\cp -a /tmp/backup.conf '+get.path); return public.returnMsg(False,'ERROR:<br><font style="color:red;">'+isError.replace("\n",'<br>')+'</font>'); public.serviceReload(); public.WriteLog('TYPE_FILE','FILE_SAVE_SUCCESS',(get.path,)); return public.returnMsg(True,'FILE_SAVE_SUCCESS'); except: return public.returnMsg(False,'FILE_SAVE_ERR');
def ModifyRedirect(self, get): # 基本信息检查 if self.__CheckRedirectStart(get): return self.__CheckRedirectStart(get) redirectconf = self.__read_config(self.__redirectfile) for i in range(len(redirectconf)): if redirectconf[i][ "redirectname"] == get.redirectname and redirectconf[i][ "sitename"] == get.sitename: redirectconf[i]["tourl"] = get.tourl redirectconf[i]["redirectdomain"] = json.loads( get.redirectdomain) redirectconf[i]["redirectpath"] = get.redirectpath redirectconf[i]["redirecttype"] = get.redirecttype redirectconf[i]["type"] = int(get.type) redirectconf[i]["domainorpath"] = get.domainorpath redirectconf[i]["holdpath"] = int(get.holdpath) self.__write_config(self.__redirectfile, redirectconf) self.SetRedirect(get) self.SetRedirectNginx(get) self.SetRedirectApache(get.sitename) public.serviceReload() return public.returnMsg(True, 'EDIT_SUCCESS')
def ClearOther(self): clearPath = [ {'path':'/www/server/panel','find':'testDisk_'}, {'path':'/www/wwwlogs','find':'log'}, {'path':'/tmp','find':'panelBoot.pl'}, {'path':'/www/server/panel/install','find':'.rpm'} ] total = count = 0; for c in clearPath: for d in os.listdir(c['path']): if d.find(c['find']) == -1: continue; filename = c['path'] + '/' + d; if os.path.isdir(filename): continue fsize = os.path.getsize(filename); total += fsize os.remove(filename) count += 1; public.serviceReload(); filename = '/www/server/nginx/off' if os.path.exists(filename): os.remove(filename) os.system('echo > /tmp/panelBoot.pl'); return total,count
def GetSSLInfo(self,get): self.__PDATA['data']['partnerOrderId'] = get.partnerOrderId; self.__PDATA['data'] = self.De_Code(self.__PDATA['data']); result = json.loads(public.httpPost(self.__APIURL + '/GetSSLInfo',self.__PDATA)); result['data'] = self.En_Code(result['data']); #写配置到站点 if hasattr(get,'siteName'): try: siteName = get.siteName; path = '/etc/letsencrypt/live/'+ siteName; if not os.path.exists(path): public.ExecShell('mkdir -p ' + path) csrpath = path+"/fullchain.pem"; keypath = path+"/privkey.pem"; pidpath = path+"/partnerOrderId"; #清理旧的证书链 public.ExecShell('rm -f ' + keypath) public.ExecShell('rm -f ' + csrpath) public.ExecShell('rm -rf ' + path + '-00*') public.ExecShell('rm -rf /etc/letsencrypt/archive/' + get.siteName) public.ExecShell('rm -rf /etc/letsencrypt/archive/' + get.siteName + '-00*') public.ExecShell('rm -f /etc/letsencrypt/renewal/'+ get.siteName + '.conf') public.ExecShell('rm -f /etc/letsencrypt/renewal/'+ get.siteName + '-00*.conf') public.ExecShell('rm -f ' + path + '/README'); public.writeFile(keypath,result['data']['privateKey']); public.writeFile(csrpath,result['data']['cert']+result['data']['certCa']); public.writeFile(pidpath,get.partnerOrderId); import panelSite panelSite.panelSite().SetSSLConf(get); public.serviceReload(); return public.returnMsg(True,'SET_SUCCESS'); except Exception as ex: return public.returnMsg(False,'SET_ERROR,' + str(ex)); result['data'] = self.En_Code(result['data']); return result;
def set_pma_access(): try: pma_path = get_pma_path() if not pma_path: return False if not os.path.exists(pma_path): return False pma_tmp = pma_path + '/tmp' if not os.path.exists(pma_tmp): os.makedirs(pma_tmp) nginx_file = '/www/server/nginx/conf/nginx.conf' if os.path.exists(nginx_file): nginx_conf = public.readFile(nginx_file) if nginx_conf.find('/tmp/') == -1: r_conf = '''/www/server/phpmyadmin; location ~ /tmp/ { return 403; }''' nginx_conf = nginx_conf.replace('/www/server/phpmyadmin;', r_conf) public.writeFile(nginx_file, nginx_conf) public.serviceReload() apa_pma_tmp = pma_tmp + '/.htaccess' if not os.path.exists(apa_pma_tmp): r_conf = '''order allow,deny deny from all''' public.writeFile(apa_pma_tmp, r_conf) public.set_mode(apa_pma_tmp, 755) public.set_own(apa_pma_tmp, 'root') public.ExecShell("chmod -R 700 {}".format(pma_tmp)) public.ExecShell("chown -R www:www {}".format(pma_tmp)) return True except: return False
def set_auto_index(self, args): ''' # 添加自动索引目录 author: zhwen<*****@*****.**> :param args: website 网站名 str :param args: index_name 规则名称 str :param args: dir 自动索引目录 str :param args: act 操作方法 :return: ''' if self.webserver == 'openlitespeed': return public.returnMsg(False, 'Sorry, OLS does not currently support this feature') tmp = self._check_args(args) if tmp: return tmp deny_name = args.index_name dir = args.dir website = args.website self._init_conf(website) conf = public.readFile(self.ng_website_conf) if not conf: return False data = re.findall('BEGIN_AUTOINDEX_.*', conf) exist_index_name = [i.split('_')[-1] for i in data] if args.act == 'edit': if deny_name not in exist_index_name: return public.returnMsg(False, 'The specify rule name is not exists! [ {} ]'.format(deny_name)) self.del_auto_index(args) else: if deny_name in exist_index_name: return public.returnMsg(False, 'The specify rule name is already exists! [ {} ]'.format(deny_name)) self._set_nginx_auto_index(deny_name, dir) self._set_apache_auto_index(deny_name, dir) public.serviceReload() return public.returnMsg(True, 'Add Successfully')
def delete_dir_auth(self, get): ''' get.id get.name :param get: :return: ''' name = get.name site_info = self.get_site_info(get.id) site_name = site_info["site_name"] conf = self._read_conf() if site_name not in conf: return public.returnMsg( False, "The website does not exist in the configuration:{}".format( site_name)) for i in range(len(conf[site_name])): if name in conf[site_name][i].values(): print(conf[site_name][i]) del (conf[site_name][i]) if not conf[site_name]: del (conf[site_name]) break public.writeFile(self.conf_file, json.dumps(conf)) for i in ["nginx", "apache"]: file_path = "{setup_path}/panel/vhost/{webserver}/dir_auth/{site_name}/{name}.conf".format( webserver=i, setup_path=self.setup_path, site_name=site_name, name=name) os.remove(file_path) if not conf: self.set_conf(site_name, "delete") if not hasattr(get, 'multiple'): public.serviceReload() return public.returnMsg(True, "DEL_SUCCESS")
def set_cert(self, get): siteName = get.siteName certInfo = self.get_order_find(get) path = '/www/server/panel/vhost/cert/' + siteName if not os.path.exists(path): public.ExecShell('mkdir -p ' + path) csrpath = path + "/fullchain.pem" keypath = path + "/privkey.pem" pidpath = path + "/certOrderId" other_file = path + '/partnerOrderId' if os.path.exists(other_file): os.remove(other_file) other_file = path + '/README' if os.path.exists(other_file): os.remove(other_file) public.writeFile(keypath, certInfo['privateKey']) public.writeFile( csrpath, certInfo['certificate'] + "\n" + certInfo['caCertificate']) public.writeFile(pidpath, get.oid) import panelSite panelSite.panelSite().SetSSLConf(get) public.serviceReload() return public.returnMsg(True, 'SET_SUCCESS')
def setPHPMaxTime(self,get): time = get.time version = get.version; if int(time) < 30 or int(time) > 86400: return public.returnMsg(False,'PHP_TIMEOUT_ERR'); file = web.ctx.session.setupPath+'/php/'+version+'/etc/php-fpm.conf'; conf = public.readFile(file); rep = "request_terminate_timeout\s*=\s*([0-9]+)\n"; conf = re.sub(rep,"request_terminate_timeout = "+time+"\n",conf); public.writeFile(file,conf) file = '/www/server/php/'+version+'/etc/php.ini'; phpini = public.readFile(file); rep = "max_execution_time\s*=\s*([0-9]+)\r?\n"; phpini = re.sub(rep,"max_execution_time = "+time+"\n",phpini); rep = "max_input_time\s*=\s*([0-9]+)\r?\n"; phpini = re.sub(rep,"max_input_time = "+time+"\n",phpini); public.writeFile(file,phpini) if public.get_webserver() == 'nginx': #设置Nginx path = web.ctx.session.setupPath+'/nginx/conf/nginx.conf'; conf = public.readFile(path); rep = "fastcgi_connect_timeout\s+([0-9]+);"; tmp = re.search(rep, conf).groups(); if int(tmp[0]) < time: conf = re.sub(rep,'fastcgi_connect_timeout '+time+';',conf); rep = "fastcgi_send_timeout\s+([0-9]+);"; conf = re.sub(rep,'fastcgi_send_timeout '+time+';',conf); rep = "fastcgi_read_timeout\s+([0-9]+);"; conf = re.sub(rep,'fastcgi_read_timeout '+time+';',conf); public.writeFile(path,conf); public.WriteLog("TYPE_PHP", "PHP_TIMEOUT",(version,time)); public.serviceReload() public.phpReload(version); return public.returnMsg(True, 'SET_SUCCESS');
def SetupPackage(self,get): name = get.dname site_name = get.site_name; php_version = get.php_version; #取基础信息 find = public.M('sites').where('name=?',(site_name,)).field('id,path').find(); path = find['path']; #获取包信息 pinfo = self.GetPackageInfo(name); if not pinfo: return public.returnMsg(False,'指定软件包不存在!'); #检查本地包 self.WriteLogs(json.dumps({'name':'检查软件包','total':0,'used':0,'pre':0,'speed':0})); packageZip = self.__setupPath + '/package/' + name + '.zip'; isDownload = False; if os.path.exists(packageZip): md5str = self.GetFileMd5(packageZip); if md5str != pinfo['md5']: isDownload = True; else: isDownload = True; #下载文件 if isDownload: self.WriteLogs(json.dumps({'name':'下载文件','total':0,'used':0,'pre':0,'speed':0})); self.DownloadFile(pinfo['download'], packageZip); if not os.path.exists(packageZip): return public.returnMsg(False,'文件下载失败!'); os.system('unzip -o '+packageZip+' -d ' + path + '/'); #设置权限 self.WriteLogs(json.dumps({'name':'设置权限','total':0,'used':0,'pre':0,'speed':0})); os.system('chmod -R 755 ' + path); os.system('chown -R www.www ' + path); if pinfo['chmod'] != "": access = pinfo['chmod'].split(',') for chm in access: tmp = chm.split('|'); if len(tmp) != 2: continue; os.system('chmod -R ' + tmp[0] + ' ' + path + '/' + tmp[1]); #安装PHP扩展 self.WriteLogs(json.dumps({'name':'安装必要的PHP扩展','total':0,'used':0,'pre':0,'speed':0})); if pinfo['ext'] != '': exts = pinfo['ext'].split(','); import files mfile = files.files(); for ext in exts: if ext == 'pathinfo': import config con = config.config(); get.version = php_version; get.type = 'on'; con.setPathInfo(get); else: get.name = ext get.version = php_version get.type = '1'; mfile.InstallSoft(get); #执行额外shell进行依赖安装 self.WriteLogs(json.dumps({'name':'执行额外SHELL','total':0,'used':0,'pre':0,'speed':0})); if os.path.exists(path+'/install.sh'): os.system('cd '+path+' && bash ' + 'install.sh'); os.system('rm -f ' + path+'/install.sh') #是否执行Composer if os.path.exists(path + '/composer.json'): self.WriteLogs(json.dumps({'name':'执行Composer','total':0,'used':0,'pre':0,'speed':0})); if not os.path.exists(path + '/composer.lock'): execPHP = '/www/server/php/' + php_version +'/bin/php'; if execPHP: if public.get_url().find('125.88'): os.system('cd ' +path+' && '+execPHP+' /usr/bin/composer config repo.packagist composer https://packagist.phpcomposer.com'); import panelSite; phpini = '/www/server/php/' + php_version + '/etc/php.ini' phpiniConf = public.readFile(phpini); phpiniConf = phpiniConf.replace('proc_open,proc_get_status,',''); public.writeFile(phpini,phpiniConf); os.system('nohup cd '+path+' && '+execPHP+' /usr/bin/composer install -vvv > /tmp/composer.log 2>&1 &'); #写伪静态 self.WriteLogs(json.dumps({'name':'设置伪静态','total':0,'used':0,'pre':0,'speed':0})); swfile = path + '/nginx.rewrite'; if os.path.exists(swfile): rewriteConf = public.readFile(swfile); dwfile = self.__panelPath + '/vhost/rewrite/' + site_name + '.conf'; public.writeFile(dwfile,rewriteConf); #设置运行目录 self.WriteLogs(json.dumps({'name':'设置运行目录','total':0,'used':0,'pre':0,'speed':0})); if pinfo['run'] != '/': import panelSite; siteObj = panelSite.panelSite(); mobj = obj(); mobj.id = find['id']; mobj.runPath = pinfo['run']; siteObj.SetSiteRunPath(mobj); #导入数据 self.WriteLogs(json.dumps({'name':'导入数据库','total':0,'used':0,'pre':0,'speed':0})); if os.path.exists(path+'/import.sql'): databaseInfo = public.M('databases').where('pid=?',(find['id'],)).field('username,password').find(); if databaseInfo: os.system('/www/server/mysql/bin/mysql -u' + databaseInfo['username'] + ' -p' + databaseInfo['password'] + ' ' + databaseInfo['username'] + ' < ' + path + '/import.sql'); os.system('rm -f ' + path + '/import.sql'); siteConfigFile = path + '/' + pinfo['config']; if os.path.exists(siteConfigFile): siteConfig = public.readFile(siteConfigFile) siteConfig = siteConfig.replace('BT_DB_USERNAME',databaseInfo['username']) siteConfig = siteConfig.replace('BT_DB_PASSWORD',databaseInfo['password']) siteConfig = siteConfig.replace('BT_DB_NAME',databaseInfo['username']) public.writeFile(siteConfigFile,siteConfig) public.serviceReload(); self.depTotal(name); self.WriteLogs(json.dumps({'name':'准备部署','total':0,'used':0,'pre':0,'speed':0})); return public.returnMsg(True,pinfo);
def __write_config(self): public.writeFile(self.__plugin_path + '/config.json',json.dumps(self.__config)) public.serviceReload();
def __write_rule(self, ruleName, rule): path = self.__path + 'rule/' + ruleName + '.json' public.writeFile(path, json.dumps(rule)) public.serviceReload()
def set_dir_auth(self, get): ''' get.name auth_name get.site_dir auth_dir get.username username get.password password get.id site id :param get: :return: ''' name = get.name site_dir = get.site_dir if not hasattr(get, "password") or not get.password or not hasattr( get, "username") or not get.username: return public.returnMsg(False, 'Please enter an account or password') if not get.site_dir: return public.returnMsg( False, 'Please enter the directory to be protected') if not get.name: return public.returnMsg(False, 'Please enter the Name') if site_dir[0] != "/" or site_dir[-1] != "/": return public.returnMsg(False, 'Directory format is incorrect') # site_dir = site_dir[1:] # if site_dir[-1] == "/": # site_dir = site_dir[:-1] passwd = public.hasPwd(get.password) site_info = self.get_site_info(get.id) site_name = site_info["site_name"] if self._check_site_authorization(site_name): return public.returnMsg( False, 'Site password protection has been set, please cancel and then set. Site directory --> Password access' ) if self._check_dir_auth(site_name, name, site_dir): return public.returnMsg(False, 'Directory has been protected') auth = "{user}:{passwd}".format(user=get.username, passwd=passwd) auth_file = '{setup_path}/pass/{site_name}'.format( setup_path=self.setup_path, site_name=site_name) if not os.path.exists(auth_file): os.makedirs(auth_file) auth_file = auth_file + "/{}.pass".format(name) public.writeFile(auth_file, auth) # 配置独立认证文件 self.set_dir_auth_file(site_info["site_path"], site_name, name, get.username, site_dir, auth_file) # 配置站点主文件 result = self.set_conf(site_name, "create") if result: return result # 检查配置 webserver = public.get_webserver() result = self.check_site_conf(webserver, site_name, name) if result: return result # 写配置 conf = {"name": name, "site_dir": get.site_dir, "auth_file": auth_file} self._write_conf(conf, site_name) public.serviceReload() return public.returnMsg(True, "Created successfully")
def CheckStatusConf(self): if public.get_webserver() != 'nginx': return filename = session[ 'setupPath'] + '/panel/vhost/nginx/phpfpm_status.conf' if os.path.exists(filename): if public.ReadFile(filename).find('74.sock') != -1: return conf = '''server { listen 80; server_name 127.0.0.1; allow 127.0.0.1; location /nginx_status { stub_status on; access_log off; } location /phpfpm_52_status { fastcgi_pass unix:/tmp/php-cgi-52.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_53_status { fastcgi_pass unix:/tmp/php-cgi-53.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_54_status { fastcgi_pass unix:/tmp/php-cgi-54.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_55_status { fastcgi_pass unix:/tmp/php-cgi-55.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_56_status { fastcgi_pass unix:/tmp/php-cgi-56.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_70_status { fastcgi_pass unix:/tmp/php-cgi-70.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_71_status { fastcgi_pass unix:/tmp/php-cgi-71.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_72_status { fastcgi_pass unix:/tmp/php-cgi-72.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_73_status { fastcgi_pass unix:/tmp/php-cgi-73.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } location /phpfpm_74_status { fastcgi_pass unix:/tmp/php-cgi-74.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$fastcgi_script_name; } }''' public.writeFile(filename, conf) public.serviceReload()
def setPHPMyAdmin(self, get): import re #try: if public.get_webserver() == 'nginx': filename = public.GetConfigValue( 'setup_path') + '/nginx/conf/nginx.conf' else: filename = public.GetConfigValue( 'setup_path') + '/apache/conf/extra/httpd-vhosts.conf' conf = public.readFile(filename) if hasattr(get, 'port'): mainPort = public.readFile('data/port.pl').strip() rulePort = [ '80', '443', '21', '20', '8080', '8081', '8089', '11211', '6379' ] if get.port in rulePort: return public.returnMsg(False, 'AJAX_PHPMYADMIN_PORT_ERR') if public.get_webserver() == 'nginx': rep = "listen\s+([0-9]+)\s*;" oldPort = re.search(rep, conf).groups()[0] conf = re.sub(rep, 'listen ' + get.port + ';\n', conf) else: rep = "Listen\s+([0-9]+)\s*\n" oldPort = re.search(rep, conf).groups()[0] conf = re.sub(rep, "Listen " + get.port + "\n", conf, 1) rep = "VirtualHost\s+\*:[0-9]+" conf = re.sub(rep, "VirtualHost *:" + get.port, conf, 1) if oldPort == get.port: return public.returnMsg(False, 'SOFT_PHPVERSION_ERR_PORT') public.writeFile(filename, conf) import firewalls get.ps = public.getMsg('SOFT_PHPVERSION_PS') fw = firewalls.firewalls() fw.AddAcceptPort(get) public.serviceReload() public.WriteLog('TYPE_SOFT', 'SOFT_PHPMYADMIN_PORT', (get.port, )) get.id = public.M('firewall').where('port=?', (oldPort, )).getField('id') get.port = oldPort fw.DelAcceptPort(get) return public.returnMsg(True, 'SET_PORT_SUCCESS') if hasattr(get, 'phpversion'): if public.get_webserver() == 'nginx': filename = public.GetConfigValue( 'setup_path') + '/nginx/conf/enable-php.conf' conf = public.readFile(filename) rep = "php-cgi.*\.sock" conf = re.sub(rep, 'php-cgi-' + get.phpversion + '.sock', conf, 1) else: rep = "php-cgi.*\.sock" conf = re.sub(rep, 'php-cgi-' + get.phpversion + '.sock', conf, 1) public.writeFile(filename, conf) public.serviceReload() public.WriteLog('TYPE_SOFT', 'SOFT_PHPMYADMIN_PHP', (get.phpversion, )) return public.returnMsg(True, 'SOFT_PHPVERSION_SET') if hasattr(get, 'password'): import panelSite if (get.password == 'close'): return panelSite.panelSite().CloseHasPwd(get) else: return panelSite.panelSite().SetHasPwd(get) if hasattr(get, 'status'): if conf.find(public.GetConfigValue('setup_path') + '/stop') != -1: conf = conf.replace( public.GetConfigValue('setup_path') + '/stop', public.GetConfigValue('setup_path') + '/phpmyadmin') msg = public.getMsg('START') else: conf = conf.replace( public.GetConfigValue('setup_path') + '/phpmyadmin', public.GetConfigValue('setup_path') + '/stop') msg = public.getMsg('STOP') public.writeFile(filename, conf) public.serviceReload() public.WriteLog('TYPE_SOFT', 'SOFT_PHPMYADMIN_STATUS', (msg, )) return public.returnMsg(True, 'SOFT_PHPMYADMIN_STATUS', (msg, ))
def SetupPackage(self,get): name = get.dname site_name = get.site_name; php_version = get.php_version; #取基础信息 find = public.M('sites').where('name=?',(site_name,)).field('id,path,name').find(); path = find['path']; if path.replace('//','/') == '/': return public.returnMsg(False,'Dangerous website root directory!') #获取包信息 pinfo = self.GetPackageInfo(name); id = pinfo['id'] if not pinfo: return public.returnMsg(False,'The specified package does not exist.!'); #检查本地包 self.WriteLogs(json.dumps({'name':'Verifying package...','total':0,'used':0,'pre':0,'speed':0})); pack_path = self.__panelPath + '/package' if not os.path.exists(pack_path): os.makedirs(pack_path,384) packageZip = pack_path + '/'+ name + '.zip'; isDownload = False; if os.path.exists(packageZip): md5str = self.GetFileMd5(packageZip); if md5str != pinfo['versions'][0]['md5']: isDownload = True; else: isDownload = True; #下载文件 if isDownload: self.WriteLogs(json.dumps({'name':'Downloading file ...','total':0,'used':0,'pre':0,'speed':0})); if pinfo['versions'][0]['download']: self.DownloadFile('http://www.bt.cn/api/Pluginother/get_file?fname=' + pinfo['versions'][0]['download'], packageZip); if not os.path.exists(packageZip): return public.returnMsg(False,'File download failed!' + packageZip); pinfo = self.set_temp_file(packageZip,path) if not pinfo: return public.returnMsg(False,'Cannot find [aaPanel Auto Deployment Configuration File] in the installation package') #设置权限 self.WriteLogs(json.dumps({'name':'Setting permissions','total':0,'used':0,'pre':0,'speed':0})); os.system('chmod -R 755 ' + path); os.system('chown -R www.www ' + path); if pinfo['chmod'] != "": for chm in pinfo['chmod']: os.system('chmod -R ' + str(chm['mode']) + ' ' + (path + '/' + chm['path']).replace('//','/')); #安装PHP扩展 self.WriteLogs(json.dumps({'name':'Install the necessary PHP extensions','total':0,'used':0,'pre':0,'speed':0})); import files mfile = files.files(); for ext in pinfo['php_ext']: if ext == 'pathinfo': import config con = config.config(); get.version = php_version; get.type = 'on'; con.setPathInfo(get); else: get.name = ext get.version = php_version get.type = '1'; mfile.InstallSoft(get); #解禁PHP函数 if 'enable_functions' in pinfo: try: php_f = public.GetConfigValue('setup_path') + '/php/' + php_version + '/etc/php.ini' php_c = public.readFile(php_f) rep = "disable_functions\s*=\s{0,1}(.*)\n" tmp = re.search(rep,phpini).groups(); disable_functions = tmp[0].split(','); for fun in pinfo['enable_functions']: fun = fun.strip() if fun in disable_functions: disable_functions.remove(fun) disable_functions = ','.join(disable_functions) php_c = re.sub(rep, 'disable_functions = ' + disable_functions + "\n", php_c); public.writeFile(php_f,php_c) public.phpReload(php_version) except:pass #执行额外shell进行依赖安装 self.WriteLogs(json.dumps({'name':'Execute extra SHELL','total':0,'used':0,'pre':0,'speed':0})); if os.path.exists(path+'/install.sh'): os.system('cd '+path+' && bash ' + 'install.sh ' + find['name']); os.system('rm -f ' + path+'/install.sh') #是否执行Composer if os.path.exists(path + '/composer.json'): self.WriteLogs(json.dumps({'name':'Execute Composer','total':0,'used':0,'pre':0,'speed':0})); if not os.path.exists(path + '/composer.lock'): execPHP = '/www/server/php/' + php_version +'/bin/php'; if execPHP: if public.get_url().find('125.88'): os.system('cd ' +path+' && '+execPHP+' /usr/bin/composer config repo.packagist composer https://packagist.phpcomposer.com'); import panelSite; phpini = '/www/server/php/' + php_version + '/etc/php.ini' phpiniConf = public.readFile(phpini); phpiniConf = phpiniConf.replace('proc_open,proc_get_status,',''); public.writeFile(phpini,phpiniConf); os.system('nohup cd '+path+' && '+execPHP+' /usr/bin/composer install -vvv > /tmp/composer.log 2>&1 &'); #写伪静态 self.WriteLogs(json.dumps({'name':'Set URL rewrite','total':0,'used':0,'pre':0,'speed':0})); swfile = path + '/nginx.rewrite'; if os.path.exists(swfile): rewriteConf = public.readFile(swfile); dwfile = self.__panelPath + '/vhost/rewrite/' + site_name + '.conf'; public.writeFile(dwfile,rewriteConf); #删除伪静态文件 public.ExecShell("rm -f " + path + '/*.rewrite') #删除多余文件 rm_file = path + '/index.html' if os.path.exists(rm_file): rm_file_body = public.readFile(rm_file) if rm_file_body.find('panel-heading') != -1: os.remove(rm_file) #设置运行目录 self.WriteLogs(json.dumps({'name':'Set the run directory','total':0,'used':0,'pre':0,'speed':0})); if pinfo['run_path'] != '/': import panelSite; siteObj = panelSite.panelSite(); mobj = obj(); mobj.id = find['id']; mobj.runPath = pinfo['run_path']; siteObj.SetSiteRunPath(mobj); #导入数据 self.WriteLogs(json.dumps({'name':'Import database','total':0,'used':0,'pre':0,'speed':0})); if os.path.exists(path+'/import.sql'): databaseInfo = public.M('databases').where('pid=?',(find['id'],)).field('username,password').find(); if databaseInfo: os.system('/www/server/mysql/bin/mysql -u' + databaseInfo['username'] + ' -p' + databaseInfo['password'] + ' ' + databaseInfo['username'] + ' < ' + path + '/import.sql'); os.system('rm -f ' + path + '/import.sql'); siteConfigFile = (path + '/' + pinfo['db_config']).replace('//','/'); if os.path.exists(siteConfigFile): siteConfig = public.readFile(siteConfigFile) siteConfig = siteConfig.replace('BT_DB_USERNAME',databaseInfo['username']) siteConfig = siteConfig.replace('BT_DB_PASSWORD',databaseInfo['password']) siteConfig = siteConfig.replace('BT_DB_NAME',databaseInfo['username']) public.writeFile(siteConfigFile,siteConfig) #清理文件和目录 for f_path in pinfo['remove_file']: filename = (path + '/' + f_path).replace('//','/') if os.path.exists(filename): if not os.path.isdir(filename): if f_path.find('.user.ini') != -1: public.ExecShell("chattr -i " + filename) os.remove(filename) else: public.ExecShell("rm -rf " + filename) public.serviceReload(); if id: self.depTotal(id); self.WriteLogs(json.dumps({'name':'Ready to deploy','total':0,'used':0,'pre':0,'speed':0})); return public.returnMsg(True,pinfo);
def CheckPHPINFO(self): php_versions = [ '52', '53', '54', '55', '56', '70', '71', '72', '73', '74', '75' ] path = public.GetConfigValue( 'setup_path') + '/panel/vhost/nginx/phpinfo.conf' nginx_path = '/www/server/nginx/conf/enable-php-' if not os.path.exists(path) or not os.path.exists(nginx_path + '75.conf'): opt = "" for version in php_versions: opt += "\n\tlocation /" + version + " {\n\t\tinclude enable-php-" + version + ".conf;\n\t}" nginx_conf = nginx_path + version + '.conf' if not os.path.exists(nginx_conf): nginx_body = '''location ~ [^/]\.php(/|$) { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi-%s.sock; fastcgi_index index.php; include fastcgi.conf; include pathinfo.conf; }''' % version public.WriteFile(nginx_conf, nginx_body) phpinfoBody = '''server { listen 80; server_name 127.0.0.2; allow 127.0.0.1; index phpinfo.php index.html index.php; root /www/server/phpinfo; %s }''' % (opt, ) public.writeFile(path, phpinfoBody) path = public.GetConfigValue( 'setup_path') + '/panel/vhost/apache/phpinfo.conf' if not os.path.exists(path): opt = "" for version in php_versions: opt += """\n<Location /%s> SetHandler "proxy:unix:/tmp/php-cgi-%s.sock|fcgi://localhost" </Location>""" % (version, version) try: apacheVersion = public.readFile( '/www/server/apache/version.pl').strip() if apacheVersion == '2.2': opt = "" except: pass phpinfoBody = ''' <VirtualHost *:80> DocumentRoot "/www/server/phpinfo" ServerAdmin phpinfo ServerName 127.0.0.2 %s <Directory "/www/server/phpinfo"> SetOutputFilter DEFLATE Options FollowSymLinks AllowOverride All Order allow,deny Allow from all DirectoryIndex index.php index.html index.htm default.php default.html default.htm </Directory> </VirtualHost> ''' % (opt, ) public.writeFile(path, phpinfoBody) public.serviceReload()
def __write_site_config(self, site_config): public.writeFile(self.__path + 'site.json', json.dumps(site_config)) public.serviceReload()
def SetupPackage(self, get): name = get.dname site_name = get.site_name php_version = get.php_version #取基础信息 find = public.M('sites').where('name=?', (site_name, )).field('id,path').find() path = find['path'] #获取包信息 pinfo = self.GetPackageInfo(name) if not pinfo: return public.returnMsg(False, '指定软件包不存在!') #检查本地包 self.WriteLogs( json.dumps({ 'name': '检查软件包', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) packageZip = self.__setupPath + '/package/' + name + '.zip' isDownload = False if os.path.exists(packageZip): md5str = self.GetFileMd5(packageZip) if md5str != pinfo['md5']: isDownload = True else: isDownload = True #下载文件 if isDownload: self.WriteLogs( json.dumps({ 'name': '下载文件', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) self.DownloadFile(pinfo['download'], packageZip) if not os.path.exists(packageZip): return public.returnMsg(False, '文件下载失败!') os.system('unzip -o ' + packageZip + ' -d ' + path + '/') #设置权限 self.WriteLogs( json.dumps({ 'name': '设置权限', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) os.system('chmod -R 755 ' + path) os.system('chown -R www.www ' + path) if pinfo['chmod'] != "": access = pinfo['chmod'].split(',') for chm in access: tmp = chm.split('|') if len(tmp) != 2: continue os.system('chmod -R ' + tmp[0] + ' ' + path + '/' + tmp[1]) #安装PHP扩展 self.WriteLogs( json.dumps({ 'name': '安装必要的PHP扩展', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if pinfo['ext'] != '': exts = pinfo['ext'].split(',') import files mfile = files.files() for ext in exts: if ext == 'pathinfo': import config con = config.config() get.version = php_version get.type = 'on' con.setPathInfo(get) else: get.name = ext get.version = php_version get.type = '1' mfile.InstallSoft(get) #执行额外shell进行依赖安装 self.WriteLogs( json.dumps({ 'name': '执行额外SHELL', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if os.path.exists(path + '/install.sh'): os.system('cd ' + path + ' && bash ' + 'install.sh') os.system('rm -f ' + path + '/install.sh') #是否执行Composer if os.path.exists(path + '/composer.json'): self.WriteLogs( json.dumps({ 'name': '执行Composer', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if not os.path.exists(path + '/composer.lock'): execPHP = '/www/server/php/' + php_version + '/bin/php' if execPHP: if public.get_url().find('125.88'): os.system( 'cd ' + path + ' && ' + execPHP + ' /usr/bin/composer config repo.packagist composer https://packagist.phpcomposer.com' ) import panelSite phpini = '/www/server/php/' + php_version + '/etc/php.ini' phpiniConf = public.readFile(phpini) phpiniConf = phpiniConf.replace( 'proc_open,proc_get_status,', '') public.writeFile(phpini, phpiniConf) os.system( 'nohup cd ' + path + ' && ' + execPHP + ' /usr/bin/composer install -vvv > /tmp/composer.log 2>&1 &' ) #写伪静态 self.WriteLogs( json.dumps({ 'name': '设置伪静态', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) swfile = path + '/nginx.rewrite' if os.path.exists(swfile): rewriteConf = public.readFile(swfile) dwfile = self.__panelPath + '/vhost/rewrite/' + site_name + '.conf' public.writeFile(dwfile, rewriteConf) #设置运行目录 self.WriteLogs( json.dumps({ 'name': '设置运行目录', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if pinfo['run'] != '/': import panelSite siteObj = panelSite.panelSite() mobj = obj() mobj.id = find['id'] mobj.runPath = pinfo['run'] siteObj.SetSiteRunPath(mobj) #导入数据 self.WriteLogs( json.dumps({ 'name': '导入数据库', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if os.path.exists(path + '/import.sql'): databaseInfo = public.M('databases').where( 'pid=?', (find['id'], )).field('username,password').find() if databaseInfo: os.system('/www/server/mysql/bin/mysql -u' + databaseInfo['username'] + ' -p' + databaseInfo['password'] + ' ' + databaseInfo['username'] + ' < ' + path + '/import.sql') os.system('rm -f ' + path + '/import.sql') siteConfigFile = path + '/' + pinfo['config'] if os.path.exists(siteConfigFile): siteConfig = public.readFile(siteConfigFile) siteConfig = siteConfig.replace('BT_DB_USERNAME', databaseInfo['username']) siteConfig = siteConfig.replace('BT_DB_PASSWORD', databaseInfo['password']) siteConfig = siteConfig.replace('BT_DB_NAME', databaseInfo['username']) public.writeFile(siteConfigFile, siteConfig) public.serviceReload() self.depTotal(name) self.WriteLogs( json.dumps({ 'name': '准备部署', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) return public.returnMsg(True, pinfo)
def set_phpmyadmin_ssl(self, get): if not os.path.exists("/www/server/panel/ssl/certificate.pem"): return public.returnMsg(False, '面板证书不存在,请申请面板证书后再试') if get.v == "1": # nginx配置文件 ssl_conf = """server { listen 887 ssl; server_name phpmyadmin; index index.html index.htm index.php; root /www/server/phpmyadmin; #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 #error_page 404/404.html; ssl_certificate /www/server/panel/ssl/certificate.pem; ssl_certificate_key /www/server/panel/ssl/privateKey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; error_page 497 https://$host$request_uri; #SSL-END include enable-php.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /\. { deny all; } access_log /www/wwwlogs/access.log; }""" public.writeFile("/www/server/panel/vhost/nginx/phpmyadmin.conf", ssl_conf) import panelPlugin get.sName = "phpmyadmin" v = panelPlugin.panelPlugin().get_soft_find(get) public.writeFile("/tmp/2", str(v["ext"]["phpversion"])) # apache配置 ssl_conf = '''Listen 887 <VirtualHost *:887> ServerAdmin [email protected] DocumentRoot "/www/server/phpmyadmin" ServerName 0b842aa5.phpmyadmin ServerAlias phpmyadmin.com #ErrorLog "/www/wwwlogs/BT_default_error.log" #CustomLog "/www/wwwlogs/BT_default_access.log" combined #SSL SSLEngine On SSLCertificateFile /www/server/panel/ssl/certificate.pem SSLCertificateKeyFile /www/server/panel/ssl/privateKey.pem SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH SSLProtocol All -SSLv2 -SSLv3 SSLHonorCipherOrder On #PHP <FilesMatch \.php$> SetHandler "proxy:unix:/tmp/php-cgi-{}.sock|fcgi://localhost" </FilesMatch> #DENY FILES <Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$> Order allow,deny Deny from all </Files> #PATH <Directory "/www/wwwroot/bt.youbadbad.cn/"> SetOutputFilter DEFLATE Options FollowSymLinks AllowOverride All Require all granted DirectoryIndex index.php index.html index.htm default.php default.html default.htm </Directory> </VirtualHost>'''.format(v["ext"]["phpversion"]) public.writeFile("/www/server/panel/vhost/apache/phpmyadmin.conf", ssl_conf) else: if os.path.exists("/www/server/panel/vhost/nginx/phpmyadmin.conf"): os.remove("/www/server/panel/vhost/nginx/phpmyadmin.conf") if os.path.exists( "/www/server/panel/vhost/apache/phpmyadmin.conf"): os.remove("/www/server/panel/vhost/apache/phpmyadmin.conf") public.serviceReload() return public.returnMsg(True, '关闭成功') public.serviceReload() return public.returnMsg(True, '开启成功,请手动放行phpmyadmin ssl端口')
def GetApacheStatus(self): process_cpu = {} apacheconf = "%s/apache/conf/httpd.conf" % (self.setupPath) confcontent = public.readFile(apacheconf) rep = "#Include conf/extra/httpd-info.conf" if re.search(rep, confcontent): confcontent = re.sub(rep, "Include conf/extra/httpd-info.conf", confcontent) public.writeFile(apacheconf, confcontent) public.serviceReload() result = public.HttpGet('http://127.0.0.1/server-status?auto') try: workermen = int( public.ExecShell( "ps aux|grep httpd|grep 'start'|awk '{memsum+=$6};END {print memsum}'" )[0]) / 1024 except: return public.returnMsg(False, "Get worker RAM False") for proc in psutil.process_iter(): if proc.name() == "httpd": self.GetProcessCpuPercent(proc.pid, process_cpu) time.sleep(0.5) data = {} # 计算启动时间 Uptime = re.search("ServerUptimeSeconds:\s+(.*)", result) if not Uptime: return public.returnMsg(False, "Get worker Uptime False") Uptime = int(Uptime.group(1)) min = Uptime / 60 hours = min / 60 days = math.floor(hours / 24) hours = math.floor(hours - (days * 24)) min = math.floor(min - (days * 60 * 24) - (hours * 60)) #格式化重启时间 restarttime = re.search("RestartTime:\s+(.*)", result) if not restarttime: return public.returnMsg(False, "Get worker Restart Time False") restarttime = restarttime.group(1) rep = "\w+,\s([\w-]+)\s([\d\:]+)\s\w+" date = re.search(rep, restarttime) if not date: return public.returnMsg(False, "Get worker date False") date = date.group(1) timedetail = re.search(rep, restarttime) if not timedetail: return public.returnMsg(False, "Get worker time detail False") timedetail = timedetail.group(2) monthen = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] n = 0 for m in monthen: if m in date: date = re.sub(m, str(n + 1), date) n += 1 date = date.split("-") date = "%s-%s-%s" % (date[2], date[1], date[0]) reqpersec = re.search("ReqPerSec:\s+(.*)", result) if not reqpersec: return public.returnMsg(False, "Get worker reqpersec False") reqpersec = reqpersec.group(1) if re.match("^\.", reqpersec): reqpersec = "%s%s" % (0, reqpersec) data["RestartTime"] = "%s %s" % (date, timedetail) data["UpTime"] = "%s day %s hour %s minute" % (str( int(days)), str(int(hours)), str(int(min))) total_acc = re.search("Total Accesses:\s+(\d+)", result) if not total_acc: return public.returnMsg(False, "Get worker TotalAccesses False") data["TotalAccesses"] = total_acc.group(1) total_kb = re.search("Total kBytes:\s+(\d+)", result) if not total_kb: return public.returnMsg(False, "Get worker TotalKBytes False") data["TotalKBytes"] = total_kb.group(1) data["ReqPerSec"] = round(float(reqpersec), 2) busywork = re.search("BusyWorkers:\s+(\d+)", result) if not busywork: return public.returnMsg(False, "Get worker BusyWorkers False") data["BusyWorkers"] = busywork.group(1) idlework = re.search("IdleWorkers:\s+(\d+)", result) if not idlework: return public.returnMsg(False, "Get worker IdleWorkers False") data["IdleWorkers"] = idlework.group(1) data["workercpu"] = round(float(process_cpu["httpd"]), 2) data["workermem"] = "%s%s" % (int(workermen), "MB") return data
def SetupPackage(self, get): name = get.dname site_name = get.site_name php_version = get.php_version #取基础信息 find = public.M('sites').where( 'name=?', (site_name, )).field('id,path,name').find() if not 'path' in find: return public.returnMsg(False, '网站不存在!') path = find['path'] if path.replace('//', '/') == '/': return public.returnMsg(False, '危险的网站根目录!') #获取包信息 pinfo = self.GetPackageInfo(name) id = pinfo['id'] if not pinfo: return public.returnMsg(False, '指定软件包不存在!') #检查本地包 self.WriteLogs( json.dumps({ 'name': '正在校验软件包...', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) pack_path = self.__panelPath + '/package' if not os.path.exists(pack_path): os.makedirs(pack_path, 384) packageZip = pack_path + '/' + name + '.zip' isDownload = False if os.path.exists(packageZip): md5str = self.GetFileMd5(packageZip) if md5str != pinfo['versions'][0]['md5']: isDownload = True else: isDownload = True #下载文件 if isDownload: self.WriteLogs( json.dumps({ 'name': '正在下载文件 ...', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if pinfo['versions'][0]['download']: self.DownloadFile( 'http://www.bt.cn/api/Pluginother/get_file?fname=' + pinfo['versions'][0]['download'], packageZip) if not os.path.exists(packageZip): return public.returnMsg(False, '文件下载失败!' + packageZip) pinfo = self.set_temp_file(packageZip, path) if not pinfo: return public.returnMsg(False, '在安装包中找不到【宝塔自动部署配置文件】') #设置权限 self.WriteLogs( json.dumps({ 'name': '设置权限', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) os.system('chmod -R 755 ' + path) os.system('chown -R www.www ' + path) if pinfo['chmod']: for chm in pinfo['chmod']: os.system('chmod -R ' + str(chm['mode']) + ' ' + (path + '/' + chm['path']).replace('//', '/')) #安装PHP扩展 self.WriteLogs( json.dumps({ 'name': '安装必要的PHP扩展', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) import files mfile = files.files() if type(pinfo['php_ext']) == str: pinfo['php_ext'] = pinfo['php_ext'].strip().split(',') for ext in pinfo['php_ext']: if ext == 'pathinfo': import config con = config.config() get.version = php_version get.type = 'on' con.setPathInfo(get) else: get.name = ext get.version = php_version get.type = '1' mfile.InstallSoft(get) #解禁PHP函数 if 'enable_functions' in pinfo: try: if type(pinfo['enable_functions']) == str: pinfo['enable_functions'] = pinfo[ 'enable_functions'].strip().split(',') php_f = public.GetConfigValue( 'setup_path') + '/php/' + php_version + '/etc/php.ini' php_c = public.readFile(php_f) rep = "disable_functions\s*=\s{0,1}(.*)\n" tmp = re.search(rep, php_c).groups() disable_functions = tmp[0].split(',') for fun in pinfo['enable_functions']: fun = fun.strip() if fun in disable_functions: disable_functions.remove(fun) disable_functions = ','.join(disable_functions) php_c = re.sub( rep, 'disable_functions = ' + disable_functions + "\n", php_c) public.writeFile(php_f, php_c) public.phpReload(php_version) except: pass #执行额外shell进行依赖安装 self.WriteLogs( json.dumps({ 'name': '执行额外SHELL', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if os.path.exists(path + '/install.sh'): os.system('cd ' + path + ' && bash ' + 'install.sh ' + find['name'] + " &> install.log") os.system('rm -f ' + path + '/install.sh') #是否执行Composer if os.path.exists(path + '/composer.json'): self.WriteLogs( json.dumps({ 'name': '执行Composer', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if not os.path.exists(path + '/composer.lock'): execPHP = '/www/server/php/' + php_version + '/bin/php' if execPHP: if public.get_url().find('125.88'): os.system( 'cd ' + path + ' && ' + execPHP + ' /usr/bin/composer config repo.packagist composer https://packagist.phpcomposer.com' ) import panelSite phpini = '/www/server/php/' + php_version + '/etc/php.ini' phpiniConf = public.readFile(phpini) phpiniConf = phpiniConf.replace( 'proc_open,proc_get_status,', '') public.writeFile(phpini, phpiniConf) os.system( 'nohup cd ' + path + ' && ' + execPHP + ' /usr/bin/composer install -vvv > /tmp/composer.log 2>&1 &' ) #写伪静态 self.WriteLogs( json.dumps({ 'name': '设置伪静态', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) swfile = path + '/nginx.rewrite' if os.path.exists(swfile): rewriteConf = public.readFile(swfile) dwfile = self.__panelPath + '/vhost/rewrite/' + site_name + '.conf' public.writeFile(dwfile, rewriteConf) swfile = path + '/.htaccess' if os.path.exists(swfile): swpath = (path + '/' + pinfo['run_path'] + '/.htaccess').replace( '//', '/') if pinfo['run_path'] != '/' and not os.path.exists(swpath): public.writeFile(swpath, public.readFile(swfile)) #删除伪静态文件 public.ExecShell("rm -f " + path + '/*.rewrite') #删除多余文件 rm_file = path + '/index.html' if os.path.exists(rm_file): rm_file_body = public.readFile(rm_file) if rm_file_body.find('panel-heading') != -1: os.remove(rm_file) #设置运行目录 self.WriteLogs( json.dumps({ 'name': '设置运行目录', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if pinfo['run_path'] != '/': import panelSite siteObj = panelSite.panelSite() mobj = obj() mobj.id = find['id'] mobj.runPath = pinfo['run_path'] siteObj.SetSiteRunPath(mobj) #导入数据 self.WriteLogs( json.dumps({ 'name': '导入数据库', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if os.path.exists(path + '/import.sql'): databaseInfo = public.M('databases').where( 'pid=?', (find['id'], )).field('username,password').find() if databaseInfo: os.system('/www/server/mysql/bin/mysql -u' + databaseInfo['username'] + ' -p' + databaseInfo['password'] + ' ' + databaseInfo['username'] + ' < ' + path + '/import.sql') os.system('rm -f ' + path + '/import.sql') siteConfigFile = (path + '/' + pinfo['db_config']).replace( '//', '/') if os.path.exists(siteConfigFile): siteConfig = public.readFile(siteConfigFile) siteConfig = siteConfig.replace('BT_DB_USERNAME', databaseInfo['username']) siteConfig = siteConfig.replace('BT_DB_PASSWORD', databaseInfo['password']) siteConfig = siteConfig.replace('BT_DB_NAME', databaseInfo['username']) public.writeFile(siteConfigFile, siteConfig) #清理文件和目录 self.WriteLogs( json.dumps({ 'name': '清理多余的文件', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) if type(pinfo['remove_file']) == str: pinfo['remove_file'] = pinfo['remove_file'].strip().split(',') print(pinfo['remove_file']) for f_path in pinfo['remove_file']: if not f_path: continue filename = (path + '/' + f_path).replace('//', '/') if os.path.exists(filename): if not os.path.isdir(filename): if f_path.find('.user.ini') != -1: public.ExecShell("chattr -i " + filename) os.remove(filename) else: public.ExecShell("rm -rf " + filename) public.serviceReload() if id: self.depTotal(id) self.WriteLogs( json.dumps({ 'name': '准备部署', 'total': 0, 'used': 0, 'pre': 0, 'speed': 0 })) return public.returnMsg(True, pinfo)
def setPHPMyAdmin(self,get): import re; #try: if public.get_webserver() == 'nginx': filename = web.ctx.session.setupPath + '/nginx/conf/nginx.conf'; else: filename = web.ctx.session.setupPath + '/apache/conf/extra/httpd-vhosts.conf'; conf = public.readFile(filename); if hasattr(get,'port'): mainPort = public.readFile('data/port.pl').strip(); if mainPort == get.port: return public.returnMsg(False,'SOFT_PHPVERSION_ERR_PORT_RE'); if public.get_webserver() == 'nginx': rep = "listen\s+([0-9]+)\s*;" oldPort = re.search(rep,conf).groups()[0]; conf = re.sub(rep,'listen ' + get.port + ';\n',conf); else: rep = "Listen\s+([0-9]+)\s*\n"; oldPort = re.search(rep,conf).groups()[0]; conf = re.sub(rep,"Listen " + get.port + "\n",conf,1); rep = "VirtualHost\s+\*:[0-9]+" conf = re.sub(rep,"VirtualHost *:" + get.port,conf,1); if oldPort == get.port: return public.returnMsg(False,'SOFT_PHPVERSION_ERR_PORT'); public.writeFile(filename,conf); import firewalls get.ps = public.getMsg('SOFT_PHPVERSION_PS'); fw = firewalls.firewalls(); fw.AddAcceptPort(get); public.serviceReload(); public.WriteLog('TYPE_SOFT','SOFT_PHPMYADMIN_PORT',(get.port,)) get.id = public.M('firewall').where('port=?',(oldPort,)).getField('id'); get.port = oldPort; fw.DelAcceptPort(get); return public.returnMsg(True,'SET_PORT_SUCCESS'); if hasattr(get,'phpversion'): if public.get_webserver() == 'nginx': filename = web.ctx.session.setupPath + '/nginx/conf/enable-php.conf'; conf = public.readFile(filename); rep = "php-cgi.*\.sock" conf = re.sub(rep,'php-cgi-' + get.phpversion + '.sock',conf,1); else: rep = "php-cgi.*\.sock" conf = re.sub(rep,'php-cgi-' + get.phpversion + '.sock',conf,1); public.writeFile(filename,conf); public.serviceReload(); public.WriteLog('TYPE_SOFT','SOFT_PHPMYADMIN_PHP',(get.phpversion,)) return public.returnMsg(True,'SOFT_PHPVERSION_SET'); if hasattr(get,'password'): import panelSite; if(get.password == 'close'): return panelSite.panelSite().CloseHasPwd(get); else: return panelSite.panelSite().SetHasPwd(get); if hasattr(get,'status'): if conf.find(web.ctx.session.setupPath + '/stop') != -1: conf = conf.replace(web.ctx.session.setupPath + '/stop',web.ctx.session.setupPath + '/phpmyadmin'); msg = public.getMsg('START') else: conf = conf.replace(web.ctx.session.setupPath + '/phpmyadmin',web.ctx.session.setupPath + '/stop'); msg = public.getMsg('STOP') public.writeFile(filename,conf); public.serviceReload(); public.WriteLog('TYPE_SOFT','SOFT_PHPMYADMIN_STATUS',(msg,)) return public.returnMsg(True,'SOFT_PHPMYADMIN_STATUS',(msg,));