MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / DeleteSite

Method DeleteSite

mod/project/php/php_asyncMod.py:620–711  ·  view source on GitHub ↗
(self, get, multiple=None)

Source from the content-addressed store, hash-verified

618
619 # 删除站点
620 def DeleteSite(self, get, multiple=None):
621 try:
622 proxyconf = [] if not os.path.exists(self.__proxyfile) else json.loads(public.readFile(self.__proxyfile))
623 id = get.id
624 if public.M('sites').where('id=?', (id,)).count() < 1: return public.returnResult(False, '指定站点不存在!')
625 siteName = get.webname
626 get.siteName = siteName
627 # 删除反向代理
628 for i in range(len(proxyconf) - 1, -1, -1):
629 if proxyconf[i]["sitename"] == siteName:
630 del proxyconf[i]
631 public.writeFile(self.__proxyfile, json.dumps(proxyconf))
632 m_path = self.setupPath + '/panel/vhost/nginx/proxy/' + siteName
633 if os.path.exists(m_path): public.ExecShell("rm -rf %s" % m_path)
634
635 # 删除目录保护
636 _dir_aith_file = "%s/panel/data/site_dir_auth.json" % self.setupPath
637 _dir_aith_conf = public.readFile(_dir_aith_file)
638 # 删除保护目录
639 if _dir_aith_conf:
640 try:
641 _dir_aith_conf = json.loads(_dir_aith_conf)
642 if siteName in _dir_aith_conf:
643 del (_dir_aith_conf[siteName])
644 except:
645 pass
646 public.writeFile(_dir_aith_file, _dir_aith_conf)
647 dir_aith_path = self.setupPath + '/panel/vhost/nginx/dir_auth/' + siteName
648 if os.path.exists(dir_aith_path): public.ExecShell("rm -rf %s" % dir_aith_path)
649
650 # 删除重定向
651 __redirectfile = "%s/panel/data/redirect.conf" % self.setupPath
652 redirectconf = [] if not os.path.exists(__redirectfile) else json.loads(public.readFile(__redirectfile))
653 for i in range(len(redirectconf) - 1, -1, -1):
654 if redirectconf[i]["sitename"] == siteName:
655 del redirectconf[i]
656 public.writeFile(__redirectfile, json.dumps(redirectconf))
657 m_path = self.setupPath + '/panel/vhost/nginx/redirect/' + siteName
658 if os.path.exists(m_path): public.ExecShell("rm -rf %s" % m_path)
659
660 # 删除配置文件
661 confPath = self.setupPath + '/panel/vhost/nginx/' + siteName + '.conf'
662 if os.path.exists(confPath): os.remove(confPath)
663
664 # 删除伪静态文件
665 filename = '/www/server/panel/vhost/rewrite/' + siteName + '.conf'
666 if os.path.exists(filename):
667 os.remove(filename)
668 public.ExecShell("rm -f " + confPath + '/rewrite/' + siteName + "_*")
669
670 # 删除日志文件
671 filename = public.GetConfigValue('logs_path') + '/' + siteName + '*'
672 public.ExecShell("rm -f " + filename)
673
674 # 重载服务
675 public.serviceReload()
676
677 # 从数据库删除

Callers 2

delete_siteFunction · 0.45
remove_siteFunction · 0.45

Calls 15

RedirectClass · 0.90
RealServerClass · 0.90
readFileMethod · 0.80
returnResultMethod · 0.80
writeFileMethod · 0.80
ExecShellMethod · 0.80
DeleteUserMethod · 0.80
existsMethod · 0.45
loadsMethod · 0.45
countMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected