mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-13 08:46:09 +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 loginSystem.models import Administrator, ACL
|
||||||
from django.shortcuts import HttpResponse
|
from django.shortcuts import HttpResponse
|
||||||
from packages.models import Package
|
from packages.models import Package
|
||||||
from websiteFunctions.models import Websites, ChildDomains, aliasDomains, DockerSites
|
from websiteFunctions.models import Websites, ChildDomains, aliasDomains, DockerSites, WPSites
|
||||||
import json
|
import json
|
||||||
from subprocess import call, CalledProcessError
|
from subprocess import call, CalledProcessError
|
||||||
from shlex import split
|
from shlex import split
|
||||||
@@ -582,25 +582,45 @@ class ACLManager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def searchWebsiteObjects(currentACL, userID, searchTerm):
|
def searchWebsiteObjects(currentACL, userID, searchTerm):
|
||||||
|
|
||||||
if currentACL['admin'] == 1:
|
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:
|
else:
|
||||||
websiteList = []
|
websiteList = []
|
||||||
admin = Administrator.objects.get(pk=userID)
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
# Get websites that match the search term
|
||||||
websites = admin.websites_set.filter(domain__istartswith=searchTerm)
|
websites = admin.websites_set.filter(domain__istartswith=searchTerm)
|
||||||
|
|
||||||
for items in websites:
|
for items in websites:
|
||||||
websiteList.append(items)
|
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:
|
for items in admins:
|
||||||
|
# Get websites that match the search term
|
||||||
webs = items.websites_set.filter(domain__istartswith=searchTerm)
|
webs = items.websites_set.filter(domain__istartswith=searchTerm)
|
||||||
for web in webs:
|
for web in webs:
|
||||||
|
if web not in websiteList:
|
||||||
websiteList.append(web)
|
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
|
return websiteList
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-10" style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
|
<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>
|
class="form-control" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -4566,8 +4566,7 @@ StrictHostKeyChecking no
|
|||||||
|
|
||||||
websites = ACLManager.searchWebsiteObjects(currentlACL, userID, searchTerm)
|
websites = ACLManager.searchWebsiteObjects(currentlACL, userID, searchTerm)
|
||||||
|
|
||||||
json_data = "["
|
json_data = []
|
||||||
checker = 0
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ipFile = "/etc/cyberpanel/machineIP"
|
ipFile = "/etc/cyberpanel/machineIP"
|
||||||
@@ -4598,19 +4597,34 @@ StrictHostKeyChecking no
|
|||||||
PHPVersionActual = 'PHP 8.1'
|
PHPVersionActual = 'PHP 8.1'
|
||||||
|
|
||||||
diskUsed = "%sMB" % str(DiskUsage)
|
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:
|
# Get WordPress sites for this website
|
||||||
json_data = json_data + json.dumps(dic)
|
wp_sites = []
|
||||||
checker = 1
|
try:
|
||||||
else:
|
wp_sites = WPSites.objects.filter(owner=items)
|
||||||
json_data = json_data + ',' + json.dumps(dic)
|
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):
|
def findWebsitesJson(self, currentACL, userID, pageNumber):
|
||||||
finalPageNumber = ((pageNumber * 10)) - 10
|
finalPageNumber = ((pageNumber * 10)) - 10
|
||||||
|
|||||||
Reference in New Issue
Block a user