mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 16:26:12 +01:00
bug fix: with website search and wpsites
This commit is contained in:
@@ -14,7 +14,7 @@ django.setup()
|
||||
from loginSystem.models import Administrator, ACL
|
||||
from django.shortcuts import HttpResponse
|
||||
from packages.models import Package
|
||||
from websiteFunctions.models import Websites, ChildDomains, aliasDomains, DockerSites
|
||||
from websiteFunctions.models import Websites, ChildDomains, aliasDomains, DockerSites, WPSites
|
||||
import json
|
||||
from subprocess import call, CalledProcessError
|
||||
from shlex import split
|
||||
@@ -582,25 +582,45 @@ class ACLManager:
|
||||
|
||||
@staticmethod
|
||||
def searchWebsiteObjects(currentACL, userID, searchTerm):
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
return Websites.objects.filter(domain__istartswith=searchTerm)
|
||||
# Get websites that match the search term
|
||||
websites = Websites.objects.filter(domain__istartswith=searchTerm)
|
||||
# Get WordPress sites that match the search term
|
||||
wp_sites = WPSites.objects.filter(title__icontains=searchTerm)
|
||||
# Add WordPress sites' parent websites to the results
|
||||
for wp in wp_sites:
|
||||
if wp.owner not in websites:
|
||||
websites = websites | Websites.objects.filter(pk=wp.owner.pk)
|
||||
return websites
|
||||
else:
|
||||
websiteList = []
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
# Get websites that match the search term
|
||||
websites = admin.websites_set.filter(domain__istartswith=searchTerm)
|
||||
|
||||
for items in websites:
|
||||
websiteList.append(items)
|
||||
|
||||
admins = Administrator.objects.filter(owner=admin.pk)
|
||||
# Get WordPress sites that match the search term
|
||||
wp_sites = WPSites.objects.filter(title__icontains=searchTerm)
|
||||
for wp in wp_sites:
|
||||
if wp.owner.admin == admin and wp.owner not in websiteList:
|
||||
websiteList.append(wp.owner)
|
||||
|
||||
admins = Administrator.objects.filter(owner=admin.pk)
|
||||
for items in admins:
|
||||
# Get websites that match the search term
|
||||
webs = items.websites_set.filter(domain__istartswith=searchTerm)
|
||||
for web in webs:
|
||||
if web not in websiteList:
|
||||
websiteList.append(web)
|
||||
|
||||
# Get WordPress sites that match the search term
|
||||
wp_sites = WPSites.objects.filter(title__icontains=searchTerm)
|
||||
for wp in wp_sites:
|
||||
if wp.owner.admin == items and wp.owner not in websiteList:
|
||||
websiteList.append(wp.owner)
|
||||
|
||||
return websiteList
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-sm-10" style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
|
||||
<input ng-change="searchWebsites()" placeholder="Search..." ng-model="patternAdded" name="dom" type="text"
|
||||
<input ng-keypress="$event.keyCode === 13 && searchWebsites()" placeholder="Search... (Press Enter to search)" ng-model="patternAdded" name="dom" type="text"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4566,8 +4566,7 @@ StrictHostKeyChecking no
|
||||
|
||||
websites = ACLManager.searchWebsiteObjects(currentlACL, userID, searchTerm)
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
json_data = []
|
||||
|
||||
try:
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
@@ -4598,19 +4597,34 @@ StrictHostKeyChecking no
|
||||
PHPVersionActual = 'PHP 8.1'
|
||||
|
||||
diskUsed = "%sMB" % str(DiskUsage)
|
||||
dic = {'domain': items.domain, 'adminEmail': items.adminEmail, 'ipAddress': ipAddress,
|
||||
'admin': items.admin.userName, 'package': items.package.packageName, 'state': state,
|
||||
'diskUsed': diskUsed, 'phpVersion': PHPVersionActual}
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
# Get WordPress sites for this website
|
||||
wp_sites = []
|
||||
try:
|
||||
wp_sites = WPSites.objects.filter(owner=items)
|
||||
wp_sites = [{
|
||||
'id': wp.id,
|
||||
'title': wp.title,
|
||||
'url': wp.FinalURL,
|
||||
'version': wp.version if hasattr(wp, 'version') else 'Unknown',
|
||||
'phpVersion': wp.phpVersion if hasattr(wp, 'phpVersion') else 'Unknown'
|
||||
} for wp in wp_sites]
|
||||
except:
|
||||
pass
|
||||
|
||||
json_data = json_data + ']'
|
||||
json_data.append({
|
||||
'domain': items.domain,
|
||||
'adminEmail': items.adminEmail,
|
||||
'ipAddress': ipAddress,
|
||||
'admin': items.admin.userName,
|
||||
'package': items.package.packageName,
|
||||
'state': state,
|
||||
'diskUsed': diskUsed,
|
||||
'phpVersion': PHPVersionActual,
|
||||
'wp_sites': wp_sites
|
||||
})
|
||||
|
||||
return json_data
|
||||
return json.dumps(json_data)
|
||||
|
||||
def findWebsitesJson(self, currentACL, userID, pageNumber):
|
||||
finalPageNumber = ((pageNumber * 10)) - 10
|
||||
|
||||
Reference in New Issue
Block a user