mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
add back fetchwpsitesfor domain
This commit is contained in:
@@ -7122,3 +7122,97 @@ StrictHostKeyChecking no
|
|||||||
else:
|
else:
|
||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
return redirect(reverse('pricing'))
|
return redirect(reverse('pricing'))
|
||||||
|
|
||||||
|
def fetchWPSitesForDomain(self, userID=None, data=None):
|
||||||
|
try:
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
domain = data['domain']
|
||||||
|
website = Websites.objects.get(domain=domain)
|
||||||
|
|
||||||
|
if ACLManager.checkOwnership(domain, admin, currentACL) != 1:
|
||||||
|
return ACLManager.loadErrorJson('fetchStatus', 0)
|
||||||
|
|
||||||
|
wp_sites = WPSites.objects.filter(owner=website)
|
||||||
|
sites = []
|
||||||
|
|
||||||
|
Vhuser = website.externalApp
|
||||||
|
PHPVersion = website.phpSelection
|
||||||
|
|
||||||
|
php = ACLManager.getPHPString(PHPVersion)
|
||||||
|
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||||
|
|
||||||
|
for site in wp_sites:
|
||||||
|
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s 2>/dev/null' % (
|
||||||
|
Vhuser, FinalPHPPath, site.path)
|
||||||
|
version = ProcessUtilities.outputExecutioner(command, None, True)
|
||||||
|
version = html.escape(version)
|
||||||
|
|
||||||
|
# Get current theme
|
||||||
|
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp theme list --status=active --field=name --skip-plugins --skip-themes --path=%s 2>/dev/null' % (
|
||||||
|
Vhuser, FinalPHPPath, site.path)
|
||||||
|
currentTheme = ProcessUtilities.outputExecutioner(command, None, True)
|
||||||
|
currentTheme = currentTheme.strip()
|
||||||
|
|
||||||
|
# Get number of plugins
|
||||||
|
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin list --field=name --skip-plugins --skip-themes --path=%s 2>/dev/null' % (
|
||||||
|
Vhuser, FinalPHPPath, site.path)
|
||||||
|
plugins = ProcessUtilities.outputExecutioner(command, None, True)
|
||||||
|
pluginCount = len([p for p in plugins.split('\n') if p.strip()])
|
||||||
|
|
||||||
|
# Generate screenshot URL
|
||||||
|
site_url = site.FinalURL
|
||||||
|
if not site_url.startswith(('http://', 'https://')):
|
||||||
|
site_url = f'https://{site_url}'
|
||||||
|
|
||||||
|
|
||||||
|
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config list --skip-plugins --skip-themes --path=%s' % (
|
||||||
|
Vhuser, FinalPHPPath, site.path)
|
||||||
|
stdout = ProcessUtilities.outputExecutioner(command)
|
||||||
|
debugging = 0
|
||||||
|
for items in stdout.split('\n'):
|
||||||
|
if items.find('WP_DEBUG true constant') > -1:
|
||||||
|
debugging = 1
|
||||||
|
break
|
||||||
|
|
||||||
|
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp option get blog_public --skip-plugins --skip-themes --path=%s' % (
|
||||||
|
Vhuser, FinalPHPPath, site.path)
|
||||||
|
stdoutput = ProcessUtilities.outputExecutioner(command)
|
||||||
|
searchindex = int(stdoutput.splitlines()[-1])
|
||||||
|
|
||||||
|
|
||||||
|
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp maintenance-mode status --skip-plugins --skip-themes --path=%s' % (
|
||||||
|
Vhuser, FinalPHPPath, site.path)
|
||||||
|
maintenanceMod = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
|
result = maintenanceMod.splitlines()[-1]
|
||||||
|
if result.find('not active') > -1:
|
||||||
|
maintenanceMode = 0
|
||||||
|
else:
|
||||||
|
maintenanceMode = 1
|
||||||
|
|
||||||
|
sites.append({
|
||||||
|
'id': site.id,
|
||||||
|
'title': site.title,
|
||||||
|
'url': site.FinalURL,
|
||||||
|
'path': site.path,
|
||||||
|
'version': version,
|
||||||
|
'phpVersion': site.owner.phpSelection,
|
||||||
|
'theme': currentTheme,
|
||||||
|
'activePlugins': pluginCount,
|
||||||
|
'debugging': debugging,
|
||||||
|
'searchIndex': searchindex,
|
||||||
|
'maintenanceMode': maintenanceMode,
|
||||||
|
'screenshot': f'https://api.microlink.io/?url={site_url}&screenshot=true&meta=false&embed=screenshot.url'
|
||||||
|
})
|
||||||
|
|
||||||
|
data_ret = {'status': 1, 'fetchStatus': 1, 'error_message': "None", "sites": sites}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user