2019-12-10 23:04:24 +05:00
|
|
|
#!/usr/local/CyberCP/bin/python
|
2018-08-18 00:39:10 +05:00
|
|
|
import os,sys
|
2022-01-26 12:49:07 +05:00
|
|
|
|
2022-02-28 15:09:15 +05:00
|
|
|
from manageServices.models import PDNSStatus
|
2022-01-26 12:49:07 +05:00
|
|
|
from .processUtilities import ProcessUtilities
|
|
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
sys.path.append('/usr/local/CyberCP')
|
|
|
|
|
import django
|
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
|
|
|
|
django.setup()
|
|
|
|
|
from loginSystem.models import Administrator, ACL
|
|
|
|
|
from django.shortcuts import HttpResponse
|
|
|
|
|
from packages.models import Package
|
2021-08-20 19:42:06 +05:00
|
|
|
from websiteFunctions.models import Websites, ChildDomains, aliasDomains
|
2018-08-18 00:39:10 +05:00
|
|
|
import json
|
2018-08-28 01:19:34 +05:00
|
|
|
from subprocess import call, CalledProcessError
|
|
|
|
|
from shlex import split
|
2019-12-11 10:40:35 +05:00
|
|
|
from .CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
2019-01-08 22:38:33 +05:00
|
|
|
from dockerManager.models import Containers
|
2020-03-20 19:18:37 +05:00
|
|
|
from re import compile
|
2022-06-05 12:46:02 +05:00
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
class ACLManager:
|
|
|
|
|
|
2021-03-14 10:54:12 +05:00
|
|
|
|
|
|
|
|
AdminACL = '{"adminStatus":1, "versionManagement": 1, "createNewUser": 1, "listUsers": 1, "deleteUser":1 , "resellerCenter": 1, ' \
|
|
|
|
|
'"changeUserACL": 1, "createWebsite": 1, "modifyWebsite": 1, "suspendWebsite": 1, "deleteWebsite": 1, ' \
|
|
|
|
|
'"createPackage": 1, "listPackages": 1, "deletePackage": 1, "modifyPackage": 1, "createDatabase": 1, "deleteDatabase": 1, ' \
|
|
|
|
|
'"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \
|
|
|
|
|
'"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \
|
|
|
|
|
'"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \
|
2021-04-15 19:47:12 -04:00
|
|
|
' "restoreBackup": 1, "addDeleteDestinations": 1, "scheduleBackups": 1, "remoteBackups": 1, "googleDriveBackups": 1, "manageSSL": 1, ' \
|
2021-03-14 10:54:12 +05:00
|
|
|
'"hostnameSSL": 1, "mailServerSSL": 1 }'
|
|
|
|
|
|
|
|
|
|
ResellerACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 1, "listUsers": 1, "deleteUser": 1 , "resellerCenter": 1, ' \
|
|
|
|
|
'"changeUserACL": 0, "createWebsite": 1, "modifyWebsite": 1, "suspendWebsite": 1, "deleteWebsite": 1, ' \
|
|
|
|
|
'"createPackage": 1, "listPackages": 1, "deletePackage": 1, "modifyPackage": 1, "createDatabase": 1, "deleteDatabase": 1, ' \
|
|
|
|
|
'"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \
|
|
|
|
|
'"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \
|
|
|
|
|
'"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \
|
2021-04-15 19:47:12 -04:00
|
|
|
' "restoreBackup": 1, "addDeleteDestinations": 0, "scheduleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \
|
2021-03-14 10:54:12 +05:00
|
|
|
'"hostnameSSL": 0, "mailServerSSL": 0 }'
|
|
|
|
|
|
|
|
|
|
UserACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 0, "listUsers": 0, "deleteUser": 0 , "resellerCenter": 0, ' \
|
|
|
|
|
'"changeUserACL": 0, "createWebsite": 0, "modifyWebsite": 0, "suspendWebsite": 0, "deleteWebsite": 0, ' \
|
|
|
|
|
'"createPackage": 0, "listPackages": 0, "deletePackage": 0, "modifyPackage": 0, "createDatabase": 1, "deleteDatabase": 1, ' \
|
|
|
|
|
'"listDatabases": 1, "createNameServer": 0, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \
|
|
|
|
|
'"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \
|
|
|
|
|
'"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \
|
2021-04-15 19:47:12 -04:00
|
|
|
' "restoreBackup": 0, "addDeleteDestinations": 0, "scheduleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \
|
2021-03-14 10:54:12 +05:00
|
|
|
'"hostnameSSL": 0, "mailServerSSL": 0 }'
|
2021-08-30 12:51:18 +05:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def VerifySMTPHost(currentACL, owner, user):
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif owner == user:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
2021-08-30 13:25:53 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def VerifyRecordOwner(currentACL, record, domain):
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif record.domainOwner.name == domain:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
2021-08-20 19:42:06 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def AliasDomainCheck(currentACL, aliasDomain, master):
|
|
|
|
|
aliasOBJ = aliasDomains.objects.get(aliasDomain=aliasDomain)
|
|
|
|
|
masterOBJ = Websites.objects.get(domain=master)
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif aliasOBJ.master == masterOBJ:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
2021-08-02 12:21:11 +05:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def CheckPackageOwnership(package, admin, currentACL):
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif package.admin == admin:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
2021-08-13 14:55:08 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def CheckRegEx(RegexCheck, value):
|
|
|
|
|
import re
|
|
|
|
|
if re.match(RegexCheck, value):
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
2021-08-02 12:21:11 +05:00
|
|
|
|
|
|
|
|
|
2021-04-02 12:45:42 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def FindIfChild():
|
|
|
|
|
try:
|
|
|
|
|
ipFile = "/etc/cyberpanel/machineIP"
|
|
|
|
|
f = open(ipFile)
|
|
|
|
|
ipData = f.read()
|
|
|
|
|
ipAddress = ipData.split('\n', 1)[0]
|
|
|
|
|
|
|
|
|
|
config = json.loads(open('/home/cyberpanel/cluster', 'r').read())
|
|
|
|
|
if config['failoverServerIP'] == ipAddress:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
except:
|
|
|
|
|
return 0
|
|
|
|
|
|
2021-03-14 10:54:12 +05:00
|
|
|
|
2020-03-16 19:14:39 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def fetchIP():
|
|
|
|
|
try:
|
|
|
|
|
ipFile = "/etc/cyberpanel/machineIP"
|
|
|
|
|
f = open(ipFile)
|
|
|
|
|
ipData = f.read()
|
|
|
|
|
return ipData.split('\n', 1)[0]
|
|
|
|
|
except BaseException:
|
|
|
|
|
return "192.168.100.1"
|
|
|
|
|
|
2020-03-15 21:34:26 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def validateInput(value, regex = None):
|
|
|
|
|
if regex == None:
|
|
|
|
|
verifier = compile(r'[\sa-zA-Z0-9_-]+')
|
|
|
|
|
else:
|
|
|
|
|
verifier = regex
|
|
|
|
|
|
2020-03-20 19:18:37 +05:00
|
|
|
if verifier.fullmatch(value):
|
2020-03-15 21:34:26 +05:00
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
2020-02-07 21:26:55 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def commandInjectionCheck(value):
|
2020-02-26 11:31:19 +05:00
|
|
|
try:
|
|
|
|
|
if value.find(';') > -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1 \
|
|
|
|
|
or value.find("`") > -1 or value.find("$") > -1 or value.find("(") > -1 or value.find(")") > -1 \
|
|
|
|
|
or value.find("'") > -1 or value.find("[") > -1 or value.find("]") > -1 or value.find(
|
|
|
|
|
"{") > -1 or value.find("}") > -1 \
|
|
|
|
|
or value.find(":") > -1 or value.find("<") > -1 or value.find(">") > -1:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
except BaseException as msg:
|
|
|
|
|
logging.writeToFile('%s. [32:commandInjectionCheck]' % (str(msg)))
|
2020-02-07 21:26:55 +05:00
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def loadedACL(val):
|
|
|
|
|
|
|
|
|
|
admin = Administrator.objects.get(pk=val)
|
|
|
|
|
finalResponse = {}
|
|
|
|
|
finalResponse['firstName'] = admin.firstName
|
|
|
|
|
finalResponse['lastName'] = admin.lastName
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
ipFile = "/etc/cyberpanel/machineIP"
|
|
|
|
|
f = open(ipFile)
|
|
|
|
|
ipData = f.read()
|
|
|
|
|
serverIPAddress = ipData.split('\n', 1)[0]
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2018-08-18 00:39:10 +05:00
|
|
|
serverIPAddress = "192.168.100.1"
|
|
|
|
|
|
|
|
|
|
finalResponse['serverIPAddress'] = serverIPAddress
|
2019-08-13 16:27:56 +05:00
|
|
|
finalResponse['adminName'] = admin.firstName
|
2018-08-18 00:39:10 +05:00
|
|
|
|
2021-02-23 23:38:58 +05:00
|
|
|
config = json.loads(admin.acl.config)
|
|
|
|
|
|
|
|
|
|
if config['adminStatus']:
|
2018-08-18 00:39:10 +05:00
|
|
|
finalResponse['admin'] = 1
|
|
|
|
|
else:
|
|
|
|
|
finalResponse['admin'] = 0
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['versionManagement'] = config['versionManagement']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
## User Management
|
|
|
|
|
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['createNewUser'] = config['createNewUser']
|
|
|
|
|
finalResponse['listUsers'] = config['listUsers']
|
|
|
|
|
finalResponse['deleteUser'] = config['deleteUser']
|
|
|
|
|
finalResponse['changeUserACL'] = config['changeUserACL']
|
|
|
|
|
finalResponse['resellerCenter'] = config['resellerCenter']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
## Website Management
|
|
|
|
|
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['createWebsite'] = config['createWebsite']
|
|
|
|
|
finalResponse['modifyWebsite'] = config['modifyWebsite']
|
|
|
|
|
finalResponse['suspendWebsite'] = config['suspendWebsite']
|
|
|
|
|
finalResponse['deleteWebsite'] = config['deleteWebsite']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
## Package Management
|
|
|
|
|
|
|
|
|
|
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['createPackage'] = config['createPackage']
|
|
|
|
|
finalResponse['listPackages'] = config['listPackages']
|
|
|
|
|
finalResponse['deletePackage'] = config['deletePackage']
|
|
|
|
|
finalResponse['modifyPackage'] = config['modifyPackage']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
## Database Management
|
|
|
|
|
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['createDatabase'] = config['createDatabase']
|
|
|
|
|
finalResponse['deleteDatabase'] = config['deleteDatabase']
|
|
|
|
|
finalResponse['listDatabases'] = config['listDatabases']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
## DNS Management
|
|
|
|
|
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['createNameServer'] = config['createNameServer']
|
|
|
|
|
finalResponse['createDNSZone'] = config['createDNSZone']
|
|
|
|
|
finalResponse['deleteZone'] = config['deleteZone']
|
|
|
|
|
finalResponse['addDeleteRecords'] = config['addDeleteRecords']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
## Email Management
|
|
|
|
|
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['createEmail'] = config['createEmail']
|
|
|
|
|
finalResponse['listEmails'] = config['listEmails']
|
|
|
|
|
finalResponse['deleteEmail'] = config['deleteEmail']
|
|
|
|
|
finalResponse['emailForwarding'] = config['emailForwarding']
|
|
|
|
|
finalResponse['changeEmailPassword'] = config['changeEmailPassword']
|
|
|
|
|
finalResponse['dkimManager'] = config['dkimManager']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
## FTP Management
|
|
|
|
|
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['createFTPAccount'] = config['createFTPAccount']
|
|
|
|
|
finalResponse['deleteFTPAccount'] = config['deleteFTPAccount']
|
|
|
|
|
finalResponse['listFTPAccounts'] = config['listFTPAccounts']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
## Backup Management
|
|
|
|
|
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['createBackup'] = config['createBackup']
|
|
|
|
|
finalResponse['googleDriveBackups'] = config['googleDriveBackups']
|
|
|
|
|
finalResponse['restoreBackup'] = config['restoreBackup']
|
|
|
|
|
finalResponse['addDeleteDestinations'] = config['addDeleteDestinations']
|
2021-04-15 19:47:12 -04:00
|
|
|
finalResponse['scheduleBackups'] = config['scheduleBackups']
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['remoteBackups'] = config['remoteBackups']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
## SSL Management
|
|
|
|
|
|
2021-02-22 10:18:50 +05:00
|
|
|
finalResponse['manageSSL'] = config['manageSSL']
|
|
|
|
|
finalResponse['hostnameSSL'] = config['hostnameSSL']
|
|
|
|
|
finalResponse['mailServerSSL'] = config['mailServerSSL']
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
return finalResponse
|
|
|
|
|
|
2019-08-03 14:53:31 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def checkUserOwnerShip(currentACL, owner, user):
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif owner == user:
|
|
|
|
|
return 1
|
|
|
|
|
elif owner.pk == user.owner:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
2018-08-26 04:55:51 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def currentContextPermission(currentACL, context):
|
|
|
|
|
try:
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif currentACL[context] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def createDefaultACLs():
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
## Admin ACL
|
|
|
|
|
|
2021-03-14 10:54:12 +05:00
|
|
|
newACL = ACL(name='admin', adminStatus=1, config=ACLManager.AdminACL)
|
2018-08-18 00:39:10 +05:00
|
|
|
newACL.save()
|
|
|
|
|
|
|
|
|
|
## Reseller ACL
|
|
|
|
|
|
|
|
|
|
newACL = ACL(name='reseller',
|
|
|
|
|
createNewUser=1,
|
|
|
|
|
deleteUser=1,
|
|
|
|
|
createWebsite=1,
|
|
|
|
|
resellerCenter=1,
|
|
|
|
|
modifyWebsite=1,
|
|
|
|
|
suspendWebsite=1,
|
|
|
|
|
deleteWebsite=1,
|
|
|
|
|
createPackage=1,
|
|
|
|
|
deletePackage=1,
|
|
|
|
|
modifyPackage=1,
|
|
|
|
|
createNameServer=1,
|
|
|
|
|
restoreBackup=1,
|
2021-03-14 10:54:12 +05:00
|
|
|
config=ACLManager.ResellerACL
|
2018-08-18 00:39:10 +05:00
|
|
|
)
|
|
|
|
|
newACL.save()
|
|
|
|
|
|
|
|
|
|
## User ACL
|
2021-03-14 10:54:12 +05:00
|
|
|
newACL = ACL(name='user', config=ACLManager.UserACL)
|
2018-08-18 00:39:10 +05:00
|
|
|
newACL.save()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def loadError():
|
|
|
|
|
try:
|
|
|
|
|
return HttpResponse('You are not authorized to access this resource.')
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def loadErrorJson(additionalParameter = None, additionalParameterValue = None):
|
|
|
|
|
try:
|
|
|
|
|
if additionalParameter == None:
|
|
|
|
|
finalJson = {"status": 0, "errorMessage": 'You are not authorized to access this resource.',
|
|
|
|
|
'error_message': 'You are not authorized to access this resource.',
|
|
|
|
|
}
|
|
|
|
|
else:
|
|
|
|
|
finalJson = {"status": 0, "errorMessage": 'You are not authorized to access this resource.',
|
|
|
|
|
'error_message': 'You are not authorized to access this resource.',
|
|
|
|
|
additionalParameter: additionalParameterValue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json_data = json.dumps(finalJson)
|
|
|
|
|
return HttpResponse(json_data)
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def findAllUsers():
|
|
|
|
|
userNames = []
|
|
|
|
|
allUsers = Administrator.objects.all()
|
|
|
|
|
for items in allUsers:
|
|
|
|
|
if items.userName == 'admin':
|
|
|
|
|
continue
|
|
|
|
|
userNames.append(items.userName)
|
|
|
|
|
return userNames
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def findAllACLs():
|
|
|
|
|
aclNames = []
|
|
|
|
|
allACLs = ACL.objects.all()
|
|
|
|
|
|
|
|
|
|
for items in allACLs:
|
|
|
|
|
if items.name == 'admin' or items.name == 'reseller' or items.name == 'user':
|
|
|
|
|
continue
|
|
|
|
|
else:
|
|
|
|
|
aclNames.append(items.name)
|
|
|
|
|
return aclNames
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def unFileteredACLs():
|
|
|
|
|
aclNames = []
|
|
|
|
|
allACLs = ACL.objects.all()
|
|
|
|
|
|
|
|
|
|
for items in allACLs:
|
|
|
|
|
aclNames.append(items.name)
|
|
|
|
|
|
|
|
|
|
return aclNames
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def loadAllUsers(userID):
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
adminNames = []
|
|
|
|
|
|
|
|
|
|
finalResponse = ACLManager.loadedACL(userID)
|
|
|
|
|
|
|
|
|
|
if finalResponse['admin'] == 1:
|
|
|
|
|
admins = Administrator.objects.all()
|
|
|
|
|
for items in admins:
|
|
|
|
|
if items.userName == admin.userName:
|
|
|
|
|
continue
|
|
|
|
|
adminNames.append(items.userName)
|
|
|
|
|
else:
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
for items in admins:
|
|
|
|
|
adminNames.append(items.userName)
|
|
|
|
|
|
|
|
|
|
adminNames.append(admin.userName)
|
|
|
|
|
return adminNames
|
|
|
|
|
|
2019-01-08 12:30:13 +00:00
|
|
|
@staticmethod
|
|
|
|
|
def loadUserObjects(userID):
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
adminObjects = []
|
|
|
|
|
|
|
|
|
|
finalResponse = ACLManager.loadedACL(userID)
|
|
|
|
|
|
|
|
|
|
if finalResponse['admin'] == 1:
|
|
|
|
|
return Administrator.objects.all()
|
|
|
|
|
else:
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
for items in admins:
|
|
|
|
|
adminObjects.append(items)
|
|
|
|
|
|
|
|
|
|
adminObjects.append(admin)
|
|
|
|
|
|
|
|
|
|
return adminObjects
|
|
|
|
|
|
2019-08-13 16:27:56 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def fetchTableUserObjects(userID):
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
adminObjects = []
|
|
|
|
|
|
|
|
|
|
finalResponse = ACLManager.loadedACL(userID)
|
|
|
|
|
|
|
|
|
|
if finalResponse['admin'] == 1:
|
|
|
|
|
return Administrator.objects.all().exclude(pk=userID)
|
|
|
|
|
else:
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
for items in admins:
|
|
|
|
|
adminObjects.append(items)
|
|
|
|
|
|
|
|
|
|
return adminObjects
|
|
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def loadDeletionUsers(userID, finalResponse):
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
adminNames = []
|
|
|
|
|
|
|
|
|
|
if finalResponse['admin'] == 1:
|
|
|
|
|
admins = Administrator.objects.all()
|
|
|
|
|
for items in admins:
|
|
|
|
|
if items.userName == admin.userName:
|
|
|
|
|
continue
|
|
|
|
|
adminNames.append(items.userName)
|
|
|
|
|
else:
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
for items in admins:
|
|
|
|
|
adminNames.append(items.userName)
|
|
|
|
|
|
|
|
|
|
return adminNames
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def userWithResellerPriv(userID):
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
adminNames = []
|
|
|
|
|
|
|
|
|
|
finalResponse = ACLManager.loadedACL(userID)
|
|
|
|
|
|
|
|
|
|
if finalResponse['admin'] == 1:
|
|
|
|
|
admins = Administrator.objects.all()
|
|
|
|
|
for items in admins:
|
|
|
|
|
if items.acl.resellerCenter == 1:
|
|
|
|
|
if items.userName == admin.userName:
|
|
|
|
|
continue
|
|
|
|
|
adminNames.append(items.userName)
|
|
|
|
|
else:
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
for items in admins:
|
|
|
|
|
if items.acl.resellerCenter == 1:
|
|
|
|
|
adminNames.append(items.userName)
|
|
|
|
|
|
|
|
|
|
adminNames.append(admin.userName)
|
|
|
|
|
return adminNames
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def websitesLimitCheck(currentAdmin, websitesLimit, userToBeModified = None):
|
|
|
|
|
if currentAdmin.acl.adminStatus != 1:
|
|
|
|
|
|
|
|
|
|
if currentAdmin.initWebsitesLimit != 0:
|
|
|
|
|
webLimits = 0
|
|
|
|
|
allUsers = Administrator.objects.filter(owner=currentAdmin.pk)
|
|
|
|
|
for items in allUsers:
|
|
|
|
|
webLimits = webLimits + items.initWebsitesLimit
|
|
|
|
|
|
|
|
|
|
if userToBeModified != None:
|
|
|
|
|
webLimits = webLimits - userToBeModified.initWebsitesLimit
|
|
|
|
|
|
|
|
|
|
webLimits = webLimits + websitesLimit + currentAdmin.websites_set.all().count()
|
|
|
|
|
|
|
|
|
|
if webLimits <= currentAdmin.initWebsitesLimit:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
else:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def loadPackages(userID, finalResponse):
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
packNames = []
|
|
|
|
|
|
|
|
|
|
if finalResponse['admin'] == 1:
|
|
|
|
|
packs = Package.objects.all()
|
|
|
|
|
for items in packs:
|
|
|
|
|
packNames.append(items.packageName)
|
|
|
|
|
else:
|
|
|
|
|
packs = admin.package_set.all()
|
|
|
|
|
for items in packs:
|
|
|
|
|
packNames.append(items.packageName)
|
|
|
|
|
|
|
|
|
|
return packNames
|
|
|
|
|
|
2019-01-08 12:30:13 +00:00
|
|
|
@staticmethod
|
|
|
|
|
def loadPackageObjects(userID, finalResponse):
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
|
|
|
|
|
if finalResponse['admin'] == 1:
|
|
|
|
|
return Package.objects.all()
|
|
|
|
|
else:
|
|
|
|
|
return admin.package_set.all()
|
|
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
@staticmethod
|
2020-05-07 13:36:32 +05:00
|
|
|
def findAllSites(currentACL, userID, fetchChilds = 0):
|
2018-08-18 00:39:10 +05:00
|
|
|
websiteNames = []
|
|
|
|
|
|
|
|
|
|
if currentACL['admin'] == 1:
|
2021-02-19 21:52:11 +05:00
|
|
|
allWebsites = Websites.objects.all().order_by('domain')
|
2020-05-07 13:36:32 +05:00
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
for items in allWebsites:
|
|
|
|
|
websiteNames.append(items.domain)
|
2020-05-07 13:36:32 +05:00
|
|
|
|
|
|
|
|
if fetchChilds:
|
2021-02-19 21:52:11 +05:00
|
|
|
for child in items.childdomains_set.all().order_by('domain'):
|
2020-05-07 13:36:32 +05:00
|
|
|
websiteNames.append(child.domain)
|
2018-08-18 00:39:10 +05:00
|
|
|
else:
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
|
2021-02-19 21:52:11 +05:00
|
|
|
websites = admin.websites_set.all().order_by('domain')
|
2018-08-18 00:39:10 +05:00
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
|
|
|
|
|
for items in websites:
|
|
|
|
|
websiteNames.append(items.domain)
|
|
|
|
|
|
2020-05-07 13:36:32 +05:00
|
|
|
if fetchChilds:
|
2021-02-19 21:52:11 +05:00
|
|
|
for child in items.childdomains_set.all().order_by('domain'):
|
2020-05-07 13:36:32 +05:00
|
|
|
websiteNames.append(child.domain)
|
|
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
for items in admins:
|
2021-02-19 21:52:11 +05:00
|
|
|
webs = items.websites_set.all().order_by('domain')
|
2018-08-18 00:39:10 +05:00
|
|
|
for web in webs:
|
|
|
|
|
websiteNames.append(web.domain)
|
|
|
|
|
|
2020-05-07 13:36:32 +05:00
|
|
|
if fetchChilds:
|
2021-02-19 21:52:11 +05:00
|
|
|
for child in web.childdomains_set.all().order_by('domain'):
|
2020-05-07 13:36:32 +05:00
|
|
|
websiteNames.append(child.domain)
|
|
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
return websiteNames
|
2019-01-08 12:30:13 +00:00
|
|
|
|
2022-05-24 11:16:49 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def getPHPString(phpVersion):
|
|
|
|
|
|
|
|
|
|
if phpVersion == "PHP 5.3":
|
|
|
|
|
php = "53"
|
|
|
|
|
elif phpVersion == "PHP 5.4":
|
|
|
|
|
php = "54"
|
|
|
|
|
elif phpVersion == "PHP 5.5":
|
|
|
|
|
php = "55"
|
|
|
|
|
elif phpVersion == "PHP 5.6":
|
|
|
|
|
php = "56"
|
|
|
|
|
elif phpVersion == "PHP 7.0":
|
|
|
|
|
php = "70"
|
|
|
|
|
elif phpVersion == "PHP 7.1":
|
|
|
|
|
php = "71"
|
|
|
|
|
elif phpVersion == "PHP 7.2":
|
|
|
|
|
php = "72"
|
|
|
|
|
elif phpVersion == "PHP 7.3":
|
|
|
|
|
php = "73"
|
|
|
|
|
elif phpVersion == "PHP 7.4":
|
|
|
|
|
php = "74"
|
|
|
|
|
elif phpVersion == "PHP 8.0":
|
|
|
|
|
php = "80"
|
|
|
|
|
|
|
|
|
|
return php
|
|
|
|
|
|
2019-02-22 09:19:16 +05:00
|
|
|
@staticmethod
|
2019-02-24 15:37:19 +05:00
|
|
|
def searchWebsiteObjects(currentACL, userID, searchTerm):
|
2020-08-09 00:27:57 +05:00
|
|
|
|
2019-02-24 15:37:19 +05:00
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return Websites.objects.filter(domain__istartswith=searchTerm)
|
|
|
|
|
else:
|
|
|
|
|
websiteList = []
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
|
|
|
|
|
websites = admin.websites_set.filter(domain__istartswith=searchTerm)
|
|
|
|
|
|
|
|
|
|
for items in websites:
|
|
|
|
|
websiteList.append(items)
|
|
|
|
|
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
|
|
|
|
|
for items in admins:
|
|
|
|
|
webs = items.websites_set.filter(domain__istartswith=searchTerm)
|
|
|
|
|
for web in webs:
|
|
|
|
|
websiteList.append(web)
|
|
|
|
|
|
|
|
|
|
return websiteList
|
2019-02-22 09:19:16 +05:00
|
|
|
|
2019-01-08 12:30:13 +00:00
|
|
|
@staticmethod
|
|
|
|
|
def findWebsiteObjects(currentACL, userID):
|
2019-01-07 13:11:12 +00:00
|
|
|
if currentACL['admin'] == 1:
|
2021-02-19 21:52:11 +05:00
|
|
|
return Websites.objects.all().order_by('domain')
|
2019-01-07 13:11:12 +00:00
|
|
|
else:
|
|
|
|
|
|
2019-01-08 12:30:13 +00:00
|
|
|
websiteList = []
|
2019-01-07 13:11:12 +00:00
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
|
2021-02-19 21:52:11 +05:00
|
|
|
websites = admin.websites_set.all().order_by('domain')
|
2019-01-07 13:11:12 +00:00
|
|
|
|
2019-01-08 12:30:13 +00:00
|
|
|
for items in websites:
|
|
|
|
|
websiteList.append(items)
|
2019-01-07 13:11:12 +00:00
|
|
|
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
|
|
|
|
|
for items in admins:
|
2021-02-19 21:52:11 +05:00
|
|
|
webs = items.websites_set.all().order_by('domain')
|
2019-01-08 12:30:13 +00:00
|
|
|
for web in webs:
|
|
|
|
|
websiteList.append(web)
|
2019-01-07 13:11:12 +00:00
|
|
|
|
2019-01-08 12:30:13 +00:00
|
|
|
return websiteList
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def findAllDomains(currentACL, userID):
|
|
|
|
|
domainsList = []
|
|
|
|
|
|
|
|
|
|
if currentACL['admin'] == 1:
|
2021-02-19 21:52:11 +05:00
|
|
|
domains = Websites.objects.all().order_by('domain')
|
2018-08-18 00:39:10 +05:00
|
|
|
for items in domains:
|
2020-01-18 10:46:24 +05:00
|
|
|
domainsList.append(items.domain)
|
2022-01-26 13:10:53 +05:00
|
|
|
|
|
|
|
|
for childs in items.childdomains_set.all():
|
|
|
|
|
domainsList.append(childs.domain)
|
|
|
|
|
|
2018-08-18 00:39:10 +05:00
|
|
|
else:
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
2021-02-19 21:52:11 +05:00
|
|
|
domains = admin.websites_set.all().order_by('domain')
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
for items in domains:
|
2020-01-18 10:46:24 +05:00
|
|
|
domainsList.append(items.domain)
|
2022-01-26 13:10:53 +05:00
|
|
|
for childs in items.childdomains_set.all():
|
|
|
|
|
domainsList.append(childs.domain)
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
|
|
|
|
|
for items in admins:
|
2021-02-19 21:52:11 +05:00
|
|
|
doms = items.websites_set.all().order_by('domain')
|
2018-08-18 00:39:10 +05:00
|
|
|
for dom in doms:
|
2020-01-18 10:46:24 +05:00
|
|
|
domainsList.append(dom.domain)
|
2022-05-12 12:50:06 +05:00
|
|
|
for childs in dom.childdomains_set.all():
|
2022-01-26 13:10:53 +05:00
|
|
|
domainsList.append(childs.domain)
|
2018-08-18 00:39:10 +05:00
|
|
|
|
|
|
|
|
return domainsList
|
|
|
|
|
|
2019-09-05 00:41:40 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def findAllWebsites(currentACL, userID):
|
|
|
|
|
domainsList = []
|
|
|
|
|
|
|
|
|
|
if currentACL['admin'] == 1:
|
2021-02-19 21:52:11 +05:00
|
|
|
domains = Websites.objects.all().order_by('domain')
|
2019-09-05 00:41:40 +05:00
|
|
|
for items in domains:
|
|
|
|
|
domainsList.append(items.domain)
|
|
|
|
|
else:
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
2021-02-19 21:52:11 +05:00
|
|
|
domains = admin.websites_set.all().order_by('domain')
|
2019-09-05 00:41:40 +05:00
|
|
|
|
|
|
|
|
for items in domains:
|
|
|
|
|
domainsList.append(items.domain)
|
|
|
|
|
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
|
|
|
|
|
for items in admins:
|
2021-02-19 21:52:11 +05:00
|
|
|
doms = items.websites_set.all().order_by('domain')
|
2019-09-05 00:41:40 +05:00
|
|
|
for dom in doms:
|
|
|
|
|
domainsList.append(dom.domain)
|
|
|
|
|
return domainsList
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def checkOwnership(domain, admin, currentACL):
|
|
|
|
|
|
2022-06-05 18:34:46 +05:00
|
|
|
|
2018-08-26 04:55:51 +05:00
|
|
|
try:
|
|
|
|
|
childDomain = ChildDomains.objects.get(domain=domain)
|
2018-08-21 13:10:40 +05:00
|
|
|
|
2018-08-26 04:55:51 +05:00
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif childDomain.master.admin == admin:
|
2018-08-21 13:10:40 +05:00
|
|
|
return 1
|
|
|
|
|
else:
|
2018-08-26 04:55:51 +05:00
|
|
|
if childDomain.master.admin.owner == admin.pk:
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
domainName = Websites.objects.get(domain=domain)
|
|
|
|
|
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif domainName.admin == admin:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
if domainName.admin.owner == admin.pk:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
2018-08-21 13:10:40 +05:00
|
|
|
|
2020-06-20 22:44:55 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def checkGDriveOwnership(gD, admin, currentACL):
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif gD.owner == admin:
|
|
|
|
|
return 1
|
|
|
|
|
elif gD.owner.owner == admin.pk:
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
except:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
2019-08-16 15:18:11 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def checkOwnershipZone(domain, admin, currentACL):
|
2022-01-26 13:10:53 +05:00
|
|
|
try:
|
|
|
|
|
domain = Websites.objects.get(domain=domain)
|
|
|
|
|
except:
|
|
|
|
|
domain = ChildDomains.objects.get(domain=domain)
|
|
|
|
|
domain = domain.master
|
2019-08-16 15:18:11 +05:00
|
|
|
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
2019-09-08 20:32:20 +05:00
|
|
|
elif domain.admin == admin:
|
2019-08-16 15:18:11 +05:00
|
|
|
return 1
|
|
|
|
|
elif domain.admin.owner == admin.pk:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
2018-08-28 01:19:34 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def executeCall(command):
|
|
|
|
|
try:
|
|
|
|
|
result = call(split(command))
|
|
|
|
|
if result == 1:
|
|
|
|
|
return 0, 'Something bad happened'
|
|
|
|
|
else:
|
|
|
|
|
return 1, 'None'
|
2019-12-10 15:09:10 +05:00
|
|
|
except CalledProcessError as msg:
|
2018-08-28 01:19:34 +05:00
|
|
|
logging.writeToFile(str(msg) + ' [ACLManager.executeCall]')
|
|
|
|
|
return 0, str(msg)
|
|
|
|
|
|
2019-01-08 22:38:33 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def checkContainerOwnership(name, userID):
|
|
|
|
|
try:
|
|
|
|
|
container = Containers.objects.get(name=name)
|
|
|
|
|
currentACL = ACLManager.loadedACL(userID)
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif container.admin == admin:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
except:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def findAllContainers(currentACL, userID):
|
|
|
|
|
containerName = []
|
|
|
|
|
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
allContainers = Containers.objects.all()
|
|
|
|
|
for items in allContainers:
|
|
|
|
|
containerName.append(items.name)
|
|
|
|
|
else:
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
|
|
|
|
|
containers = admin.containers_set.all()
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
|
|
|
|
|
for items in containers:
|
|
|
|
|
containerName.append(items.name)
|
|
|
|
|
|
|
|
|
|
for items in admins:
|
|
|
|
|
cons = items.containers_set.all()
|
|
|
|
|
for con in cons:
|
|
|
|
|
containerName.append(con.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return containerName
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def findContainersObjects(currentACL, userID):
|
|
|
|
|
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return Containers.objects.all()
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
|
|
containerList = []
|
|
|
|
|
admin = Administrator.objects.get(pk=userID)
|
|
|
|
|
|
|
|
|
|
containers = admin.containers_set.all()
|
|
|
|
|
|
|
|
|
|
for items in containers:
|
|
|
|
|
containerList.append(items)
|
|
|
|
|
|
|
|
|
|
admins = Administrator.objects.filter(owner=admin.pk)
|
|
|
|
|
|
|
|
|
|
for items in admins:
|
|
|
|
|
cons = items.containers_set.all()
|
|
|
|
|
for con in cons:
|
2019-01-09 14:55:10 +05:00
|
|
|
containerList.append(con)
|
2019-01-08 22:38:33 +05:00
|
|
|
|
|
|
|
|
return containerList
|
|
|
|
|
|
2019-06-08 21:41:43 +00:00
|
|
|
@staticmethod
|
|
|
|
|
def findChildDomains(websiteNames):
|
|
|
|
|
childDomains = []
|
|
|
|
|
|
|
|
|
|
for items in websiteNames:
|
|
|
|
|
website = Websites.objects.get(domain = items)
|
2021-02-19 21:52:11 +05:00
|
|
|
for childDomain in website.childdomains_set.all().order_by('domain'):
|
2019-06-08 21:41:43 +00:00
|
|
|
childDomains.append(childDomain.domain)
|
|
|
|
|
|
2020-01-23 20:13:29 +05:00
|
|
|
return childDomains
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def checkOwnerProtection(currentACL, owner, child):
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif child.owner == owner.pk:
|
|
|
|
|
return 1
|
|
|
|
|
elif child == owner:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
2021-09-01 14:13:42 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def CheckDomainBlackList(domain):
|
2021-09-13 15:30:27 +05:00
|
|
|
import socket
|
2021-09-13 15:59:05 +05:00
|
|
|
|
2021-09-13 15:30:27 +05:00
|
|
|
BlackList = [ socket.gethostname(), 'hotmail.com', 'gmail.com', 'yandex.com', 'yahoo.com', 'localhost', 'aol.com', 'apple.com',
|
2021-09-13 15:59:05 +05:00
|
|
|
'cloudlinux.com', 'email.com', 'facebook.com', 'gmx.de', 'gmx.com', 'google.com',
|
2021-09-13 15:30:27 +05:00
|
|
|
'hushmail.com', 'icloud.com', 'inbox.com', 'imunify360.com', 'juno.com', 'live.com', 'localhost.localdomain',
|
|
|
|
|
'localhost4.localdomain4', 'localhost6.localdomain6','mail.com', 'mail.ru', 'me.com',
|
|
|
|
|
'microsoft.com', 'mxlogic.net', 'outlook.com', 'protonmail.com', 'twitter.com', 'yandex.ru']
|
2021-09-01 14:13:42 +05:00
|
|
|
|
2021-11-01 12:03:06 +05:00
|
|
|
DotsCounter = domain.count('.')
|
|
|
|
|
|
2021-09-01 14:13:42 +05:00
|
|
|
for black in BlackList:
|
2021-11-01 12:03:06 +05:00
|
|
|
if DotsCounter == 1:
|
|
|
|
|
if domain == black:
|
|
|
|
|
return 0
|
|
|
|
|
else:
|
|
|
|
|
if domain.endswith(black):
|
|
|
|
|
logging.writeToFile(black)
|
|
|
|
|
return 0
|
2021-09-01 14:13:42 +05:00
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
2021-11-16 19:12:34 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def CheckStatusFilleLoc(statusFile):
|
|
|
|
|
if (statusFile[:18] != "/home/cyberpanel/." or statusFile[:16] == "/home/cyberpanel" or statusFile[
|
|
|
|
|
:4] == '/tmp' or statusFile[
|
|
|
|
|
:18] == '/usr/local/CyberCP') \
|
|
|
|
|
and statusFile != '/usr/local/CyberCP/CyberCP/settings.py' and statusFile.find(
|
|
|
|
|
'..') == -1 and statusFile != '/home/cyberpanel/.my.cnf' and statusFile != '/home/cyberpanel/.bashrc' and statusFile != '/home/cyberpanel/.bash_logout' and statusFile != '/home/cyberpanel/.profile':
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
2021-12-23 21:14:41 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def FetchExternalApp(domain):
|
|
|
|
|
try:
|
|
|
|
|
childDomain = ChildDomains.objects.get(domain=domain)
|
|
|
|
|
|
|
|
|
|
return childDomain.master.externalApp
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
domainName = Websites.objects.get(domain=domain)
|
|
|
|
|
return domainName.externalApp
|
|
|
|
|
|
2022-01-26 12:49:07 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def CreateSecureDir():
|
|
|
|
|
### Check if upload path tmp dir is not available
|
|
|
|
|
|
|
|
|
|
UploadPath = '/usr/local/CyberCP/tmp/'
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(UploadPath):
|
|
|
|
|
command = 'mkdir %s' % (UploadPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
|
|
|
|
command = 'chown cyberpanel:cyberpanel %s' % (UploadPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
|
|
|
|
|
|
|
|
|
command = 'chmod 711 %s' % (UploadPath)
|
|
|
|
|
ProcessUtilities.executioner(command)
|
2021-12-23 21:14:41 +05:00
|
|
|
|
2020-01-23 20:13:29 +05:00
|
|
|
|
2022-02-28 15:09:15 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def GetServiceStatus(dic):
|
|
|
|
|
if os.path.exists('/home/cyberpanel/postfix'):
|
|
|
|
|
dic['emailAsWhole'] = 1
|
|
|
|
|
else:
|
|
|
|
|
dic['emailAsWhole'] = 0
|
|
|
|
|
|
|
|
|
|
if os.path.exists('/home/cyberpanel/pureftpd'):
|
|
|
|
|
dic['ftpAsWhole'] = 1
|
|
|
|
|
else:
|
|
|
|
|
dic['ftpAsWhole'] = 0
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
pdns = PDNSStatus.objects.get(pk=1)
|
|
|
|
|
dic['dnsAsWhole'] = pdns.serverStatus
|
|
|
|
|
except:
|
|
|
|
|
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
|
|
|
|
pdnsPath = '/etc/powerdns'
|
|
|
|
|
else:
|
|
|
|
|
pdnsPath = '/etc/pdns'
|
|
|
|
|
|
|
|
|
|
if os.path.exists(pdnsPath):
|
|
|
|
|
PDNSStatus(serverStatus=1).save()
|
|
|
|
|
dic['dnsAsWhole'] = 1
|
|
|
|
|
else:
|
|
|
|
|
dic['dnsAsWhole'] = 0
|
|
|
|
|
|
2022-06-05 12:46:02 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def GetALLWPObjects(currentACL, userID):
|
|
|
|
|
from websiteFunctions.models import WPSites
|
|
|
|
|
|
|
|
|
|
wpsites = WPSites.objects.none()
|
|
|
|
|
websites = ACLManager.findWebsiteObjects(currentACL, userID)
|
|
|
|
|
|
|
|
|
|
for website in websites:
|
|
|
|
|
wpsites |= website.wpsites_set.all()
|
|
|
|
|
|
|
|
|
|
return wpsites
|
|
|
|
|
|
2022-06-16 21:21:01 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def GetServerIP():
|
|
|
|
|
ipFile = "/etc/cyberpanel/machineIP"
|
|
|
|
|
f = open(ipFile)
|
|
|
|
|
ipData = f.read()
|
|
|
|
|
return ipData.split('\n', 1)[0]
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def CheckForPremFeature(feature):
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
if ProcessUtilities.decideServer() == ProcessUtilities.ent:
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
|
|
|
|
|
data = {
|
|
|
|
|
"name": feature,
|
|
|
|
|
"IP": ACLManager.GetServerIP()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
response = requests.post(url, data=json.dumps(data))
|
|
|
|
|
return response.json()['status']
|
|
|
|
|
except:
|
|
|
|
|
return 1
|
|
|
|
|
|
2022-06-22 16:37:02 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def CheckIPBackupObjectOwner(currentACL, backupobj, user):
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif backupobj.owner == user:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def CheckIPPluginObjectOwner(currentACL, backupobj, user):
|
|
|
|
|
if currentACL['admin'] == 1:
|
|
|
|
|
return 1
|
|
|
|
|
elif backupobj.owner == user:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
2022-02-28 15:09:15 +05:00
|
|
|
|