diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py
index 132f4db93..e12624ed1 100755
--- a/websiteFunctions/website.py
+++ b/websiteFunctions/website.py
@@ -1235,25 +1235,7 @@ class WebsiteManager:
admin = Administrator.objects.get(pk=userID)
backupid = data['backupid']
- DesSiteID = data['DesSite']
-
- # try:
- #
- # bwp = WPSites.objects.get(pk=int(backupid))
- #
- # if ACLManager.checkOwnership(bwp.owner.domain, admin, currentACL) == 1:
- # pass
- # else:
- # return ACLManager.loadError()
- #
- # except:
- # pass
- #
- # dwp = WPSites.objects.get(pk=int(DesSiteID))
- # if ACLManager.checkOwnership(dwp.owner.domain, admin, currentACL) == 1:
- # pass
- # else:
- # return ACLManager.loadError()
+ DesSiteID = data['DesSiteID']
Domain = data['Domain']
@@ -1949,2026 +1931,7 @@ class WebsiteManager:
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) != 1:
return ACLManager.loadError()
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['siteId'] = siteId
- extraArgs['setting'] = setting
- extraArgs['value'] = value
- background = ApplicationInstaller('UpdateWPSettings', extraArgs)
- background.start()
-
- data_ret = {'status': 1, 'error_message': 'None'}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def GetWPSitesByDomain(self, userID=None, data=None):
- try:
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- domain = data['domain']
-
- # Get the website object for the domain
- website = Websites.objects.get(domain=domain)
-
- if ACLManager.checkOwnership(domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- # Get all WP sites for this website
- wp_sites = WPSites.objects.filter(owner=website)
-
- sites_data = []
-
- for wp in wp_sites:
- # Get PHP version
- php = ACLManager.getPHPString(website.phpSelection)
- FinalPHPPath = f'/usr/local/lsws/lsphp{php}/bin/php'
-
- # Get WP version
- command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path={wp.path} 2>/dev/null'
- version = ProcessUtilities.outputExecutioner(command, None, True)
- version = version.rstrip("\n") if version else 'Unknown'
-
- # Get active plugins count
- command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp plugin list --skip-plugins --skip-themes --format=json --path={wp.path}'
- plugins_output = ProcessUtilities.outputExecutioner(command)
- try:
- plugins = json.loads(plugins_output.splitlines()[-1])
- active_plugins = len([p for p in plugins if p['status'] == 'active'])
- except:
- active_plugins = 0
-
- # Get active theme
- command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp theme list --skip-plugins --skip-themes --format=json --path={wp.path}'
- themes_output = ProcessUtilities.outputExecutioner(command)
- try:
- themes = json.loads(themes_output.splitlines()[-1])
- active_theme = next((t['name'] for t in themes if t['status'] == 'active'), 'Unknown')
- except:
- active_theme = 'Unknown'
-
- # Get other WP settings
- command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp config list --skip-plugins --skip-themes --path={wp.path}'
- config_output = ProcessUtilities.outputExecutioner(command)
- debugging = 1 if 'WP_DEBUG\ttrue\tconstant' in config_output else 0
-
- command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp option get blog_public --skip-plugins --skip-themes --path={wp.path}'
- search_index = int(ProcessUtilities.outputExecutioner(command).splitlines()[-1])
-
- command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp maintenance-mode status --skip-plugins --skip-themes --path={wp.path}'
- maintenance_output = ProcessUtilities.outputExecutioner(command)
- maintenance_mode = 0 if 'not active' in maintenance_output.splitlines()[-1] else 1
-
- # Check password protection
- vhost_pass_dir = f'/home/{domain}'
- path = f'{vhost_pass_dir}/{wp.id}'
- password_protection = 1 if os.path.exists(path) else 0
-
- sites_data.append({
- 'id': wp.id,
- 'title': wp.title,
- 'url': wp.FinalURL,
- 'version': version,
- 'phpVersion': website.phpSelection,
- 'theme': active_theme,
- 'activePlugins': active_plugins,
- 'debugging': debugging,
- 'searchIndex': search_index,
- 'maintenanceMode': maintenance_mode,
- 'passwordProtection': password_protection
- })
-
- return HttpResponse(json.dumps({
- 'status': 1,
- 'error_message': None,
- 'data': sites_data
- }))
-
- except Websites.DoesNotExist:
- return HttpResponse(json.dumps({
- 'status': 0,
- 'error_message': f'Website with domain {domain} does not exist'
- }))
- except Exception as e:
- return HttpResponse(json.dumps({
- 'status': 0,
- 'error_message': str(e)
- }))
-
-
-class WebsiteManager:
- apache = 1
- ols = 2
- lsws = 3
-
- def __init__(self, domain=None, childDomain=None):
- self.domain = domain
- self.childDomain = childDomain
-
- def createWebsite(self, request=None, userID=None, data=None):
-
- url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
- data = {
- "name": "all",
- "IP": ACLManager.GetServerIP()
- }
-
- import requests
- response = requests.post(url, data=json.dumps(data))
- Status = response.json()['status']
-
- test_domain_status = 0
-
- if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
- test_domain_status = 1
-
- currentACL = ACLManager.loadedACL(userID)
- adminNames = ACLManager.loadAllUsers(userID)
- packagesName = ACLManager.loadPackages(userID, currentACL)
- phps = PHPManager.findPHPVersions()
-
- rnpss = randomPassword.generate_pass(10)
-
- Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps, 'Randam_String': rnpss.lower(),
- 'test_domain_data': test_domain_status}
- proc = httpProc(request, 'websiteFunctions/createWebsite.html',
- Data, 'createWebsite')
- return proc.render()
-
- def WPCreate(self, request=None, userID=None, data=None):
- url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
- data = {
- "name": "wp-manager",
- "IP": ACLManager.GetServerIP()
- }
-
- import requests
- response = requests.post(url, data=json.dumps(data))
- Status = response.json()['status']
-
-
- if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
- currentACL = ACLManager.loadedACL(userID)
- adminNames = ACLManager.loadAllUsers(userID)
- packagesName = ACLManager.loadPackages(userID, currentACL)
-
- if len(packagesName) == 0:
- packagesName = ['Default']
-
- FinalVersions = []
- userobj = Administrator.objects.get(pk=userID)
- counter = 0
- try:
- import requests
- WPVersions = json.loads(requests.get('https://api.wordpress.org/core/version-check/1.7/').text)[
- 'offers']
-
- for versions in WPVersions:
- if counter == 7:
- break
- if versions['current'] not in FinalVersions:
- FinalVersions.append(versions['current'])
- counter = counter + 1
- except:
- FinalVersions = ['5.6', '5.5.3', '5.5.2']
-
- Plugins = wpplugins.objects.filter(owner=userobj)
- rnpss = randomPassword.generate_pass(10)
-
- ##
-
- test_domain_status = 1
-
- Data = {'packageList': packagesName, "owernList": adminNames, 'WPVersions': FinalVersions,
- 'Plugins': Plugins, 'Randam_String': rnpss.lower(), 'test_domain_data': test_domain_status}
- proc = httpProc(request, 'websiteFunctions/WPCreate.html',
- Data, 'createDatabase')
- return proc.render()
- else:
- from django.shortcuts import reverse
- return redirect(reverse('pricing'))
-
- def ListWPSites(self, request=None, userID=None, DeleteID=None):
- import json
- currentACL = ACLManager.loadedACL(userID)
-
- admin = Administrator.objects.get(pk=userID)
- data = {}
- wp_sites = ACLManager.GetALLWPObjects(currentACL, userID)
- data['wp'] = wp_sites
-
- try:
- if DeleteID != None:
- WPDelete = WPSites.objects.get(pk=DeleteID)
-
- if ACLManager.checkOwnership(WPDelete.owner.domain, admin, currentACL) == 1:
- WPDelete.delete()
- except BaseException as msg:
- pass
-
- sites = []
- for site in data['wp']:
- sites.append({
- 'id': site.id,
- 'title': site.title,
- 'url': site.FinalURL,
- 'production_status': True
- })
-
- context = {
- "wpsite": json.dumps(sites),
- "status": 1,
- "total_sites": len(sites),
- "debug_info": json.dumps({
- "user_id": userID,
- "is_admin": bool(currentACL.get('admin', 0)),
- "wp_sites_count": wp_sites.count()
- })
- }
-
- proc = httpProc(request, 'websiteFunctions/WPsitesList.html', context)
- return proc.render()
-
- def WPHome(self, request=None, userID=None, WPid=None, DeleteID=None):
- Data = {}
- currentACL = ACLManager.loadedACL(userID)
- WPobj = WPSites.objects.get(pk=WPid)
- admin = Administrator.objects.get(pk=userID)
-
- if ACLManager.checkOwnership(WPobj.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- try:
-
- url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
- data = {
- "name": "wp-manager",
- "IP": ACLManager.GetServerIP()
- }
-
- import requests
- response = requests.post(url, data=json.dumps(data))
- Status = response.json()['status']
-
- rnpss = randomPassword.generate_pass(10)
-
- Data['Randam_String'] = rnpss.lower()
-
- if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
- Data['wpsite'] = WPobj
- Data['test_domain_data'] = 1
-
- try:
- DeleteID = request.GET.get('DeleteID', None)
-
- if DeleteID != None:
- wstagingDelete = WPStaging.objects.get(pk=DeleteID, owner=WPobj)
- wstagingDelete.delete()
-
- except BaseException as msg:
- da = str(msg)
-
- proc = httpProc(request, 'websiteFunctions/WPsiteHome.html',
- Data, 'createDatabase')
- return proc.render()
- else:
- from django.shortcuts import reverse
- return redirect(reverse('pricing'))
- except:
- proc = httpProc(request, 'websiteFunctions/WPsiteHome.html',
- Data, 'createDatabase')
- return proc.render()
-
- def RestoreHome(self, request=None, userID=None, BackupID=None):
- Data = {}
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- if ACLManager.CheckForPremFeature('wp-manager'):
-
- Data['backupobj'] = WPSitesBackup.objects.get(pk=BackupID)
-
- if ACLManager.CheckIPBackupObjectOwner(currentACL, Data['backupobj'], admin) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- config = json.loads(Data['backupobj'].config)
- Data['FileName'] = config['name']
- try:
- Data['Backuptype'] = config['Backuptype']
-
- if Data['Backuptype'] == 'DataBase Backup' or Data['Backuptype'] == 'Website Backup':
- Data['WPsites'] = [WPSites.objects.get(pk=Data['backupobj'].WPSiteID)]
- else:
- Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
-
- except:
- Data['Backuptype'] = None
- Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
-
- proc = httpProc(request, 'websiteFunctions/WPRestoreHome.html',
- Data, 'createDatabase')
- return proc.render()
- else:
- from django.shortcuts import reverse
- return redirect(reverse('pricing'))
-
- def RemoteBackupConfig(self, request=None, userID=None, DeleteID=None):
- Data = {}
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- try:
- if DeleteID != None:
- BackupconfigDelete = RemoteBackupConfig.objects.get(pk=DeleteID)
- BackupconfigDelete.delete()
- except:
- pass
-
- if ACLManager.CheckForPremFeature('wp-manager'):
-
- Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
- allcon = RemoteBackupConfig.objects.all()
- Data['backupconfigs'] = []
- for i in allcon:
- configr = json.loads(i.config)
- if i.configtype == "SFTP":
- Data['backupconfigs'].append({
- 'id': i.pk,
- 'Type': i.configtype,
- 'HostName': configr['Hostname'],
- 'Path': configr['Path']
- })
- elif i.configtype == "S3":
- Provider = configr['Provider']
- if Provider == "Backblaze":
- Data['backupconfigs'].append({
- 'id': i.pk,
- 'Type': i.configtype,
- 'HostName': Provider,
- 'Path': configr['S3keyname']
- })
- else:
- Data['backupconfigs'].append({
- 'id': i.pk,
- 'Type': i.configtype,
- 'HostName': Provider,
- 'Path': configr['S3keyname']
- })
-
- proc = httpProc(request, 'websiteFunctions/RemoteBackupConfig.html',
- Data, 'createDatabase')
- return proc.render()
- else:
- from django.shortcuts import reverse
- return redirect(reverse('pricing'))
-
- def BackupfileConfig(self, request=None, userID=None, RemoteConfigID=None, DeleteID=None):
- Data = {}
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- Data['RemoteConfigID'] = RemoteConfigID
- RemoteConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
- try:
- if DeleteID != None:
- RemoteBackupConfigDelete = RemoteBackupSchedule.objects.get(pk=DeleteID)
- RemoteBackupConfigDelete.delete()
- except:
- pass
-
- if ACLManager.CheckForPremFeature('wp-manager'):
- Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
- allsechedule = RemoteBackupSchedule.objects.filter(RemoteBackupConfig=RemoteConfigobj)
- Data['Backupschedule'] = []
- for i in allsechedule:
- lastrun = i.lastrun
- LastRun = time.strftime('%Y-%m-%d', time.localtime(float(lastrun)))
- Data['Backupschedule'].append({
- 'id': i.pk,
- 'Name': i.Name,
- 'RemoteConfiguration': i.RemoteBackupConfig.configtype,
- 'Retention': i.fileretention,
- 'Frequency': i.timeintervel,
- 'LastRun': LastRun
- })
- proc = httpProc(request, 'websiteFunctions/BackupfileConfig.html',
- Data, 'createDatabase')
- return proc.render()
- else:
- from django.shortcuts import reverse
- return redirect(reverse('pricing'))
-
- def AddRemoteBackupsite(self, request=None, userID=None, RemoteScheduleID=None, DeleteSiteID=None):
- Data = {}
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- Data['RemoteScheduleID'] = RemoteScheduleID
- RemoteBackupScheduleobj = RemoteBackupSchedule.objects.get(pk=RemoteScheduleID)
-
- try:
- if DeleteSiteID != None:
- RemoteBackupsitesDelete = RemoteBackupsites.objects.get(pk=DeleteSiteID)
- RemoteBackupsitesDelete.delete()
- except:
- pass
-
- if ACLManager.CheckForPremFeature('wp-manager'):
- Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
- allRemoteBackupsites = RemoteBackupsites.objects.filter(owner=RemoteBackupScheduleobj)
- Data['RemoteBackupsites'] = []
- for i in allRemoteBackupsites:
- try:
- wpsite = WPSites.objects.get(pk=i.WPsites)
- Data['RemoteBackupsites'].append({
- 'id': i.pk,
- 'Title': wpsite.title,
- })
- except:
- pass
- proc = httpProc(request, 'websiteFunctions/AddRemoteBackupSite.html',
- Data, 'createDatabase')
- return proc.render()
- else:
- from django.shortcuts import reverse
- return redirect(reverse('pricing'))
-
- def WordpressPricing(self, request=None, userID=None, ):
- Data = {}
- proc = httpProc(request, 'websiteFunctions/CyberpanelPricing.html', Data, 'createWebsite')
- return proc.render()
-
- def RestoreBackups(self, request=None, userID=None, DeleteID=None):
- Data = {}
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
- data = {
- "name": "wp-manager",
- "IP": ACLManager.GetServerIP()
- }
-
- import requests
- response = requests.post(url, data=json.dumps(data))
- Status = response.json()['status']
-
- if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
-
- backobj = WPSitesBackup.objects.filter(owner=admin).order_by('-id')
-
- # if ACLManager.CheckIPBackupObjectOwner(currentACL, backobj, admin) == 1:
- # pass
- # else:
- # return ACLManager.loadError()
-
- try:
- if DeleteID != None:
- DeleteIDobj = WPSitesBackup.objects.get(pk=DeleteID)
-
- if ACLManager.CheckIPBackupObjectOwner(currentACL, DeleteIDobj, admin) == 1:
- config = DeleteIDobj.config
- conf = json.loads(config)
- FileName = conf['name']
- command = "rm -r /home/backup/%s.tar.gz" % FileName
- ProcessUtilities.executioner(command)
- DeleteIDobj.delete()
-
- except BaseException as msg:
- pass
- Data['job'] = []
-
- for sub in backobj:
- try:
- wpsite = WPSites.objects.get(pk=sub.WPSiteID)
- web = wpsite.title
- except:
- web = "Website Not Found"
-
- try:
- config = sub.config
- conf = json.loads(config)
- Backuptype = conf['Backuptype']
- BackupDestination = conf['BackupDestination']
- except:
- Backuptype = "Backup type not exists"
-
- Data['job'].append({
- 'id': sub.id,
- 'title': web,
- 'Backuptype': Backuptype,
- 'BackupDestination': BackupDestination
- })
-
- proc = httpProc(request, 'websiteFunctions/RestoreBackups.html',
- Data, 'createDatabase')
- return proc.render()
- else:
- from django.shortcuts import reverse
- return redirect(reverse('pricing'))
-
- def AutoLogin(self, request=None, userID=None):
-
- WPid = request.GET.get('id')
- currentACL = ACLManager.loadedACL(userID)
- WPobj = WPSites.objects.get(pk=WPid)
- admin = Administrator.objects.get(pk=userID)
-
- if ACLManager.checkOwnership(WPobj.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- from managePHP.phpManager import PHPManager
-
- php = PHPManager.getPHPString(WPobj.owner.phpSelection)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
- data = {
- "name": "wp-manager",
- "IP": ACLManager.GetServerIP()
- }
-
- import requests
- response = requests.post(url, data=json.dumps(data))
- Status = response.json()['status']
-
- if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
-
- ## Get title
-
- password = randomPassword.generate_pass(10)
-
- command = f'sudo -u %s {FinalPHPPath} /usr/bin/wp user create autologin %s --role=administrator --user_pass="%s" --path=%s --skip-plugins --skip-themes' % (
- WPobj.owner.externalApp, 'autologin@cloudpages.cloud', password, WPobj.path)
- ProcessUtilities.executioner(command)
-
- command = f'sudo -u %s {FinalPHPPath} /usr/bin/wp user update autologin --user_pass="%s" --path=%s --skip-plugins --skip-themes' % (
- WPobj.owner.externalApp, password, WPobj.path)
- ProcessUtilities.executioner(command)
-
- data = {}
-
- if WPobj.FinalURL.endswith('/'):
- FinalURL = WPobj.FinalURL[:-1]
- else:
- FinalURL = WPobj.FinalURL
-
- data['url'] = 'https://%s' % (FinalURL)
- data['userName'] = 'autologin'
- data['password'] = password
-
- proc = httpProc(request, 'websiteFunctions/AutoLogin.html',
- data, 'createDatabase')
- return proc.render()
- else:
- from django.shortcuts import reverse
- return redirect(reverse('pricing'))
-
- def ConfigurePlugins(self, request=None, userID=None, data=None):
-
- if ACLManager.CheckForPremFeature('wp-manager'):
- currentACL = ACLManager.loadedACL(userID)
- userobj = Administrator.objects.get(pk=userID)
-
- Selectedplugins = wpplugins.objects.filter(owner=userobj)
- # data['Selectedplugins'] = wpplugins.objects.filter(ProjectOwner=HostingCompany)
-
- Data = {'Selectedplugins': Selectedplugins, }
- proc = httpProc(request, 'websiteFunctions/WPConfigurePlugins.html',
- Data, 'createDatabase')
- return proc.render()
- else:
- from django.shortcuts import reverse
- return redirect(reverse('pricing'))
-
- def Addnewplugin(self, request=None, userID=None, data=None):
- from django.shortcuts import reverse
- if ACLManager.CheckForPremFeature('wp-manager'):
- currentACL = ACLManager.loadedACL(userID)
- adminNames = ACLManager.loadAllUsers(userID)
- packagesName = ACLManager.loadPackages(userID, currentACL)
- phps = PHPManager.findPHPVersions()
-
- Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
- proc = httpProc(request, 'websiteFunctions/WPAddNewPlugin.html',
- Data, 'createDatabase')
- return proc.render()
-
- return redirect(reverse('pricing'))
-
- def SearchOnkeyupPlugin(self, userID=None, data=None):
- try:
- if ACLManager.CheckForPremFeature('wp-manager'):
- currentACL = ACLManager.loadedACL(userID)
-
- pluginname = data['pluginname']
- # logging.CyberCPLogFileWriter.writeToFile("Plugin Name ....... %s"%pluginname)
-
- url = "http://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[search]=%s" % str(
- pluginname)
- import requests
-
- res = requests.get(url)
- r = res.json()
-
- # return proc.ajax(1, 'Done', {'plugins': r})
-
- data_ret = {'status': 1, 'plugns': r, }
-
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
- else:
- data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': 'Premium feature not available.'}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def AddNewpluginAjax(self, userID=None, data=None):
- try:
- currentACL = ACLManager.loadedACL(userID)
-
- userobj = Administrator.objects.get(pk=userID)
-
- config = data['config']
- Name = data['Name']
- # pluginname = data['pluginname']
- # logging.CyberCPLogFileWriter.writeToFile("config ....... %s"%config)
- # logging.CyberCPLogFileWriter.writeToFile(" Name ....... %s"%Name)
-
- addpl = wpplugins(Name=Name, config=json.dumps(config), owner=userobj)
- addpl.save()
-
- data_ret = {'status': 1}
-
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'AddNewpluginAjax': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def EidtPlugin(self, request=None, userID=None, pluginbID=None):
- Data = {}
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- pluginobj = wpplugins.objects.get(pk=pluginbID)
-
- if ACLManager.CheckIPPluginObjectOwner(currentACL, pluginobj, admin) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- lmo = json.loads(pluginobj.config)
- Data['Selectedplugins'] = lmo
- Data['pluginbID'] = pluginbID
- Data['BucketName'] = pluginobj.Name
-
- proc = httpProc(request, 'websiteFunctions/WPEidtPlugin.html',
- Data, 'createDatabase')
- return proc.render()
-
- def deletesPlgin(self, userID=None, data=None, ):
- try:
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- userobj = Administrator.objects.get(pk=userID)
- pluginname = data['pluginname']
- pluginbBucketID = data['pluginbBucketID']
- # logging.CyberCPLogFileWriter.writeToFile("pluginbID ....... %s" % pluginbBucketID)
- # logging.CyberCPLogFileWriter.writeToFile("pluginname ....... %s" % pluginname)
-
- obj = wpplugins.objects.get(pk=pluginbBucketID, owner=userobj)
-
- if ACLManager.CheckIPPluginObjectOwner(currentACL, obj, admin) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- ab = []
- ab = json.loads(obj.config)
- ab.remove(pluginname)
- obj.config = json.dumps(ab)
- obj.save()
-
- data_ret = {'status': 1}
-
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
- except BaseException as msg:
- data_ret = {'status': 0, 'deletesPlgin': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def Addplugineidt(self, userID=None, data=None, ):
- try:
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- userobj = Administrator.objects.get(pk=userID)
- pluginname = data['pluginname']
- pluginbBucketID = data['pluginbBucketID']
-
- # logging.CyberCPLogFileWriter.writeToFile("pluginbID ....... %s" % pluginbBucketID)
- # logging.CyberCPLogFileWriter.writeToFile("pluginname ....... %s" % pluginname)
-
- pObj = wpplugins.objects.get(pk=pluginbBucketID, owner=userobj)
-
- if ACLManager.CheckIPPluginObjectOwner(currentACL, pObj, admin) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- listofplugin = json.loads(pObj.config)
- try:
- index = listofplugin.index(pluginname)
- print('index.....%s' % index)
- if (index >= 0):
- data_ret = {'status': 0, 'deletesPlgin': 0, 'error_message': str('Already Save in your Plugin lis')}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except:
- ab = []
- ab = json.loads(pObj.config)
- ab.append(pluginname)
- pObj.config = json.dumps(ab)
- pObj.save()
-
- data_ret = {'status': 1}
-
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
- except BaseException as msg:
- data_ret = {'status': 0, 'deletesPlgin': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def modifyWebsite(self, request=None, userID=None, data=None):
- currentACL = ACLManager.loadedACL(userID)
-
- websitesName = ACLManager.findAllSites(currentACL, userID)
- phps = PHPManager.findPHPVersions()
- proc = httpProc(request, 'websiteFunctions/modifyWebsite.html',
- {'websiteList': websitesName, 'phps': phps}, 'modifyWebsite')
- return proc.render()
-
- def deleteWebsite(self, request=None, userID=None, data=None):
- currentACL = ACLManager.loadedACL(userID)
- websitesName = ACLManager.findAllSites(currentACL, userID)
- proc = httpProc(request, 'websiteFunctions/deleteWebsite.html',
- {'websiteList': websitesName}, 'deleteWebsite')
- return proc.render()
-
- def CreateNewDomain(self, request=None, userID=None, data=None):
- currentACL = ACLManager.loadedACL(userID)
- websitesName = ACLManager.findAllSites(currentACL, userID)
-
- try:
- admin = Administrator.objects.get(pk=userID)
- if admin.defaultSite == 0:
- websites = ACLManager.findWebsiteObjects(currentACL, userID)
- admin.defaultSite = websites[0].id
- admin.save()
- except:
- pass
-
- try:
- admin = Administrator.objects.get(pk=userID)
- defaultDomain = Websites.objects.get(pk=admin.defaultSite).domain
- except:
- try:
- admin = Administrator.objects.get(pk=userID)
- websites = ACLManager.findWebsiteObjects(currentACL, userID)
- admin.defaultSite = websites[0].id
- admin.save()
- defaultDomain = websites[0].domain
- except:
- defaultDomain='NONE'
-
-
- url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
- data = {
- "name": "all",
- "IP": ACLManager.GetServerIP()
- }
-
- import requests
- response = requests.post(url, data=json.dumps(data))
- Status = response.json()['status']
-
- test_domain_status = 0
-
- if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
- test_domain_status = 1
-
- rnpss = randomPassword.generate_pass(10)
- proc = httpProc(request, 'websiteFunctions/createDomain.html',
- {'websiteList': websitesName, 'phps': PHPManager.findPHPVersions(), 'Randam_String': rnpss,
- 'test_domain_data': test_domain_status, 'defaultSite': defaultDomain})
- return proc.render()
-
- def siteState(self, request=None, userID=None, data=None):
- currentACL = ACLManager.loadedACL(userID)
-
- websitesName = ACLManager.findAllSites(currentACL, userID)
-
- proc = httpProc(request, 'websiteFunctions/suspendWebsite.html',
- {'websiteList': websitesName}, 'suspendWebsite')
- return proc.render()
-
- def listWebsites(self, request=None, userID=None, data=None):
- currentACL = ACLManager.loadedACL(userID)
- pagination = self.websitePagination(currentACL, userID)
- proc = httpProc(request, 'websiteFunctions/listWebsites.html',
- {"pagination": pagination})
- return proc.render()
-
- def listChildDomains(self, request=None, userID=None, data=None):
- currentACL = ACLManager.loadedACL(userID)
- adminNames = ACLManager.loadAllUsers(userID)
- packagesName = ACLManager.loadPackages(userID, currentACL)
- phps = PHPManager.findPHPVersions()
-
- Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
- proc = httpProc(request, 'websiteFunctions/listChildDomains.html',
- Data)
- return proc.render()
-
- def listCron(self, request=None, userID=None, data=None):
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- if ACLManager.checkOwnership(request.GET.get('domain'), admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- proc = httpProc(request, 'websiteFunctions/listCron.html',
- {'domain': request.GET.get('domain')})
- return proc.render()
-
- def domainAlias(self, request=None, userID=None, data=None):
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- aliasManager = AliasManager(self.domain)
- noAlias, finalAlisList = aliasManager.fetchAlisForDomains()
-
- path = "/home/" + self.domain + "/public_html"
-
- proc = httpProc(request, 'websiteFunctions/domainAlias.html', {
- 'masterDomain': self.domain,
- 'aliases': finalAlisList,
- 'path': path,
- 'noAlias': noAlias
- })
- return proc.render()
-
- def FetchWPdata(self, userID=None, data=None):
- try:
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
-
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- 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, path)
- version = ProcessUtilities.outputExecutioner(command, None, True)
- version = html.escape(version)
-
- command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin status litespeed-cache --skip-plugins --skip-themes --path=%s' % (
- Vhuser, FinalPHPPath, path)
- lscachee = ProcessUtilities.outputExecutioner(command)
-
- if lscachee.find('Status: Active') > -1:
- lscache = 1
- else:
- lscache = 0
-
- command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config list --skip-plugins --skip-themes --path=%s' % (
- Vhuser, FinalPHPPath, 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, 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, path)
- maintenanceMod = ProcessUtilities.outputExecutioner(command)
-
- result = maintenanceMod.splitlines()[-1]
- if result.find('not active') > -1:
- maintenanceMode = 0
- else:
- maintenanceMode = 1
-
- ##### Check passwd protection
- vhostName = wpsite.owner.domain
- vhostPassDir = f'/home/{vhostName}'
- path = f'{vhostPassDir}/{WPManagerID}'
- if os.path.exists(path):
- passwd = 1
- else:
- passwd = 0
-
- #### Check WP cron
- command = "sudo -u %s cat %s/wp-config.php" % (Vhuser, wpsite.path)
- stdout = ProcessUtilities.outputExecutioner(command)
- if stdout.find("'DISABLE_WP_CRON', 'true'") > -1:
- wpcron = 1
- else:
- wpcron = 0
-
- fb = {
- 'version': version.rstrip('\n'),
- 'lscache': lscache,
- 'debugging': debugging,
- 'searchIndex': searchindex,
- 'maintenanceMode': maintenanceMode,
- 'passwordprotection': passwd,
- 'wpcron': wpcron
-
- }
-
- data_ret = {'status': 1, 'error_message': 'None', 'ret_data': fb}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def GetCurrentPlugins(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin list --skip-plugins --skip-themes --format=json --path=%s' % (
- Vhuser, FinalPHPPath, path)
- stdoutput = ProcessUtilities.outputExecutioner(command)
- json_data = stdoutput.splitlines()[-1]
-
- data_ret = {'status': 1, 'error_message': 'None', 'plugins': json_data}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def GetCurrentThemes(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp theme list --skip-plugins --skip-themes --format=json --path=%s' % (
- Vhuser, FinalPHPPath, path)
- stdoutput = ProcessUtilities.outputExecutioner(command)
- json_data = stdoutput.splitlines()[-1]
-
- data_ret = {'status': 1, 'error_message': 'None', 'themes': json_data}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def fetchstaging(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- from plogical.phpUtilities import phpUtilities
-
- json_data = phpUtilities.GetStagingInJson(wpsite.wpstaging_set.all().order_by('-id'))
-
- data_ret = {'status': 1, 'error_message': 'None', 'wpsites': json_data}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def fetchDatabase(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- php = PHPManager.getPHPString(wpsite.owner.phpSelection)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- command = f'{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path={wpsite.path} 2>/dev/null'
- retStatus, stdoutput = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp, True, None, 1)
-
- if stdoutput.find('Error:') == -1:
- DataBaseName = stdoutput.rstrip("\n")
- DataBaseName = html.escape(DataBaseName)
- else:
- data_ret = {'status': 0, 'error_message': stdoutput}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- command = f'{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config get DB_USER --skip-plugins --skip-themes --path={wpsite.path} 2>/dev/null'
- retStatus, stdoutput = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp, True, None, 1)
-
- if stdoutput.find('Error:') == -1:
- DataBaseUser = stdoutput.rstrip("\n")
- DataBaseUser = html.escape(DataBaseUser)
- else:
- data_ret = {'status': 0, 'error_message': stdoutput}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- command = f'{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config get table_prefix --skip-plugins --skip-themes --path={wpsite.path} 2>/dev/null'
- retStatus, stdoutput = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp, True, None, 1)
-
- if stdoutput.find('Error:') == -1:
- tableprefix = stdoutput.rstrip("\n")
- tableprefix = html.escape(tableprefix)
- else:
- data_ret = {'status': 0, 'error_message': stdoutput}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- data_ret = {'status': 1, 'error_message': 'None', "DataBaseUser": DataBaseUser,
- "DataBaseName": DataBaseName, 'tableprefix': tableprefix}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def SaveUpdateConfig(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- Plugins = data['Plugins']
- Themes = data['Themes']
- AutomaticUpdates = data['AutomaticUpdates']
-
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
-
- php = PHPManager.getPHPString(wpsite.owner.phpSelection)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- if AutomaticUpdates == 'Disabled':
- command = f"{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config set WP_AUTO_UPDATE_CORE false --raw --allow-root --path=" + wpsite.path
- result = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp)
-
- if result.find('Success:') == -1:
- raise BaseException(result)
- elif AutomaticUpdates == 'Minor and Security Updates':
- command = f"{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config set WP_AUTO_UPDATE_CORE minor --allow-root --path=" + wpsite.path
- result = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp)
-
- if result.find('Success:') == -1:
- raise BaseException(result)
- else:
- command = f"{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config set WP_AUTO_UPDATE_CORE true --raw --allow-root --path=" + wpsite.path
- result = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp)
-
- if result.find('Success:') == -1:
- raise BaseException(result)
-
- wpsite.AutoUpdates = AutomaticUpdates
- wpsite.PluginUpdates = Plugins
- wpsite.ThemeUpdates = Themes
- wpsite.save()
-
- data_ret = {'status': 1, 'error_message': 'None', }
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def DeploytoProduction(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- statgingID = data['StagingID']
- wpsite = WPSites.objects.get(pk=WPManagerID)
- StagingObj = WPSites.objects.get(pk=statgingID)
-
- ###
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- if ACLManager.checkOwnership(StagingObj.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- ###
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['statgingID'] = statgingID
- extraArgs['WPid'] = WPManagerID
- extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
-
- background = ApplicationInstaller('DeploytoProduction', extraArgs)
- background.start()
-
- time.sleep(2)
-
- data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
- 'tempStatusPath': extraArgs['tempStatusPath']}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def WPCreateBackup(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- Backuptype = data['Backuptype']
-
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['WPid'] = WPManagerID
- extraArgs['Backuptype'] = Backuptype
- extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
-
- background = ApplicationInstaller('WPCreateBackup', extraArgs)
- background.start()
-
- time.sleep(2)
-
- data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
- 'tempStatusPath': extraArgs['tempStatusPath']}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def RestoreWPbackupNow(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- backupid = data['backupid']
- DesSiteID = data['DesSite']
-
- # try:
- #
- # bwp = WPSites.objects.get(pk=int(backupid))
- #
- # if ACLManager.checkOwnership(bwp.owner.domain, admin, currentACL) == 1:
- # pass
- # else:
- # return ACLManager.loadError()
- #
- # except:
- # pass
- #
- # dwp = WPSites.objects.get(pk=int(DesSiteID))
- # if ACLManager.checkOwnership(dwp.owner.domain, admin, currentACL) == 1:
- # pass
- # else:
- # return ACLManager.loadError()
-
- Domain = data['Domain']
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['backupid'] = backupid
- extraArgs['DesSiteID'] = DesSiteID
- extraArgs['Domain'] = Domain
- extraArgs['path'] = data['path']
- extraArgs['home'] = data['home']
- extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
-
- background = ApplicationInstaller('RestoreWPbackupNow', extraArgs)
- background.start()
-
- time.sleep(2)
-
- data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
- 'tempStatusPath': extraArgs['tempStatusPath']}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def SaveBackupConfig(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- ConfigType = data['type']
- if ConfigType == 'SFTP':
- Hname = data['Hname']
- Uname = data['Uname']
- Passwd = data['Passwd']
- path = data['path']
- config = {
- "Hostname": Hname,
- "Username": Uname,
- "Password": Passwd,
- "Path": path
- }
- elif ConfigType == "S3":
- Provider = data['Provider']
- if Provider == "Backblaze":
- S3keyname = data['S3keyname']
- SecertKey = data['SecertKey']
- AccessKey = data['AccessKey']
- EndUrl = data['EndUrl']
- config = {
- "Provider": Provider,
- "S3keyname": S3keyname,
- "SecertKey": SecertKey,
- "AccessKey": AccessKey,
- "EndUrl": EndUrl
-
- }
- else:
- S3keyname = data['S3keyname']
- SecertKey = data['SecertKey']
- AccessKey = data['AccessKey']
- config = {
- "Provider": Provider,
- "S3keyname": S3keyname,
- "SecertKey": SecertKey,
- "AccessKey": AccessKey,
-
- }
-
- mkobj = RemoteBackupConfig(owner=admin, configtype=ConfigType, config=json.dumps(config))
- mkobj.save()
-
- time.sleep(1)
-
- data_ret = {'status': 1, 'error_message': 'None', }
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def SaveBackupSchedule(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- FileRetention = data['FileRetention']
- Backfrequency = data['Backfrequency']
- ScheduleName = data['ScheduleName']
- RemoteConfigID = data['RemoteConfigID']
- BackupType = data['BackupType']
-
- RemoteBackupConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
- Rconfig = json.loads(RemoteBackupConfigobj.config)
-
- try:
- # This code is only supposed to run if backups are s3, not for SFTP
- provider = Rconfig['Provider']
- if provider == "Backblaze":
- EndURl = Rconfig['EndUrl']
- elif provider == "Amazon":
- EndURl = "https://s3.us-east-1.amazonaws.com"
- elif provider == "Wasabi":
- EndURl = "https://s3.wasabisys.com"
-
- AccessKey = Rconfig['AccessKey']
- SecertKey = Rconfig['SecertKey']
-
- session = boto3.session.Session()
-
- client = session.client(
- 's3',
- endpoint_url=EndURl,
- aws_access_key_id=AccessKey,
- aws_secret_access_key=SecertKey,
- verify=False
- )
-
- ############Creating Bucket
- BucketName = randomPassword.generate_pass().lower()
-
- try:
- client.create_bucket(Bucket=BucketName)
- except BaseException as msg:
- logging.CyberCPLogFileWriter.writeToFile("Creating Bucket Error: %s" % str(msg))
- data_ret = {'status': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- config = {
- 'BackupType': BackupType,
- 'BucketName': BucketName
- }
- except BaseException as msg:
- config = {'BackupType': BackupType}
- pass
-
- svobj = RemoteBackupSchedule(RemoteBackupConfig=RemoteBackupConfigobj, Name=ScheduleName,
- timeintervel=Backfrequency, fileretention=FileRetention,
- config=json.dumps(config),
- lastrun=str(time.time()))
- svobj.save()
-
- data_ret = {'status': 1, 'error_message': 'None', }
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def AddWPsiteforRemoteBackup(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- WPid = data['WpsiteID']
- RemoteScheduleID = data['RemoteScheduleID']
-
- wpsiteobj = WPSites.objects.get(pk=WPid)
- WPpath = wpsiteobj.path
- VHuser = wpsiteobj.owner.externalApp
- PhpVersion = wpsiteobj.owner.phpSelection
- php = PHPManager.getPHPString(PhpVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- ####Get DB Name
-
- command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path=%s' % (
- VHuser, FinalPHPPath, WPpath)
- result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
-
- if stdout.find('Error:') > -1:
- raise BaseException(stdout)
- else:
- Finaldbname = stdout.rstrip("\n")
-
- ## Get DB obj
- try:
- DBobj = Databases.objects.get(dbName=Finaldbname)
- except:
- raise BaseException(str("DataBase Not Found"))
- RemoteScheduleIDobj = RemoteBackupSchedule.objects.get(pk=RemoteScheduleID)
-
- svobj = RemoteBackupsites(owner=RemoteScheduleIDobj, WPsites=WPid, database=DBobj.pk)
- svobj.save()
-
- data_ret = {'status': 1, 'error_message': 'None', }
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def UpdateRemoteschedules(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- ScheduleID = data['ScheduleID']
- Frequency = data['Frequency']
- FileRetention = data['FileRetention']
-
- scheduleobj = RemoteBackupSchedule.objects.get(pk=ScheduleID)
- scheduleobj.timeintervel = Frequency
- scheduleobj.fileretention = FileRetention
- scheduleobj.save()
-
- data_ret = {'status': 1, 'error_message': 'None', }
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def ScanWordpressSite(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- allweb = Websites.objects.all()
-
- childdomain = ChildDomains.objects.all()
-
- for web in allweb:
- webpath = "/home/%s/public_html/" % web.domain
- command = "cat %swp-config.php" % webpath
- result = ProcessUtilities.outputExecutioner(command, web.externalApp)
-
- if os.path.exists(ProcessUtilities.debugPath):
- logging.CyberCPLogFileWriter.writeToFile(result)
-
- if result.find('No such file or directory') == -1:
- try:
- WPSites.objects.get(path=webpath)
- except:
- wpobj = WPSites(owner=web, title=web.domain, path=webpath, FinalURL=web.domain,
- AutoUpdates="Enabled", PluginUpdates="Enabled",
- ThemeUpdates="Enabled", )
- wpobj.save()
-
- for chlid in childdomain:
- childPath = chlid.path.rstrip('/')
-
- command = "cat %s/wp-config.php" % childPath
- result = ProcessUtilities.outputExecutioner(command, chlid.master.externalApp)
-
- if os.path.exists(ProcessUtilities.debugPath):
- logging.CyberCPLogFileWriter.writeToFile(result)
-
- if result.find('No such file or directory') == -1:
- fChildPath = f'{childPath}/'
- try:
- WPSites.objects.get(path=fChildPath)
- except:
-
- wpobj = WPSites(owner=chlid.master, title=chlid.domain, path=fChildPath, FinalURL=chlid.domain,
- AutoUpdates="Enabled", PluginUpdates="Enabled",
- ThemeUpdates="Enabled", )
- wpobj.save()
-
- data_ret = {'status': 1, 'error_message': 'None', }
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def installwpcore(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
-
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- ###fetch WP version
-
- 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, path)
- version = ProcessUtilities.outputExecutioner(command, None, True)
- version = version.rstrip("\n")
-
- ###install wp core
- command = f"sudo -u {Vhuser} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp core download --force --skip-content --version={version} --path={path}"
- output = ProcessUtilities.outputExecutioner(command)
-
- data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None', 'result': output}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def dataintegrity(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
-
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- ###fetch WP version
-
- command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core verify-checksums --skip-plugins --skip-themes --path=%s' % (
- Vhuser, FinalPHPPath, path)
- result = ProcessUtilities.outputExecutioner(command)
-
- data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None', 'result': result}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def UpdatePlugins(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- plugin = data['plugin']
- pluginarray = data['pluginarray']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['plugin'] = plugin
- extraArgs['pluginarray'] = pluginarray
- extraArgs['FinalPHPPath'] = FinalPHPPath
- extraArgs['path'] = path
- extraArgs['Vhuser'] = Vhuser
-
- background = ApplicationInstaller('UpdateWPPlugin', extraArgs)
- background.start()
-
- time.sleep(2)
-
- data_ret = {'status': 1, 'error_message': 'None'}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def UpdateThemes(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- Theme = data['Theme']
- Themearray = data['Themearray']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['Theme'] = Theme
- extraArgs['Themearray'] = Themearray
- extraArgs['FinalPHPPath'] = FinalPHPPath
- extraArgs['path'] = path
- extraArgs['Vhuser'] = Vhuser
-
- background = ApplicationInstaller('UpdateWPTheme', extraArgs)
- background.start()
-
- time.sleep(2)
-
- data_ret = {'status': 1, 'error_message': 'None'}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def DeletePlugins(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- plugin = data['plugin']
- pluginarray = data['pluginarray']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['plugin'] = plugin
- extraArgs['pluginarray'] = pluginarray
- extraArgs['FinalPHPPath'] = FinalPHPPath
- extraArgs['path'] = path
- extraArgs['Vhuser'] = Vhuser
-
- background = ApplicationInstaller('DeletePlugins', extraArgs)
- background.start()
-
- time.sleep(2)
-
- data_ret = {'status': 1, 'error_message': 'None'}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def DeleteThemes(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- Theme = data['Theme']
- Themearray = data['Themearray']
- wpsite = WPSites.objects.get(pk=WPManagerID)
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['Theme'] = Theme
- extraArgs['Themearray'] = Themearray
- extraArgs['FinalPHPPath'] = FinalPHPPath
- extraArgs['path'] = path
- extraArgs['Vhuser'] = Vhuser
-
- background = ApplicationInstaller('DeleteThemes', extraArgs)
- background.start()
-
- data_ret = {'status': 1, 'error_message': 'None'}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def ChangeStatus(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- plugin = data['plugin']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin status %s --skip-plugins --skip-themes --path=%s' % (
- Vhuser, FinalPHPPath, plugin, path)
- stdoutput = ProcessUtilities.outputExecutioner(command)
-
- if stdoutput.find('Status: Active') > -1:
- command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin deactivate %s --skip-plugins --skip-themes --path=%s' % (
- Vhuser, FinalPHPPath, plugin, path)
- stdoutput = ProcessUtilities.outputExecutioner(command)
- time.sleep(3)
-
- else:
-
- command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin activate %s --skip-plugins --skip-themes --path=%s' % (
- Vhuser, FinalPHPPath, plugin, path)
- stdoutput = ProcessUtilities.outputExecutioner(command)
- time.sleep(3)
-
- data_ret = {'status': 1, 'error_message': 'None'}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def ChangeStatusThemes(self, userID=None, data=None):
- try:
- # logging.CyberCPLogFileWriter.writeToFile("Error WP ChangeStatusThemes ....... %s")
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- WPManagerID = data['WPid']
- Theme = data['theme']
- wpsite = WPSites.objects.get(pk=WPManagerID)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- path = wpsite.path
-
- Webobj = Websites.objects.get(pk=wpsite.owner_id)
-
- Vhuser = Webobj.externalApp
- PHPVersion = Webobj.phpSelection
- php = ACLManager.getPHPString(PHPVersion)
- FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['Theme'] = Theme
- extraArgs['FinalPHPPath'] = FinalPHPPath
- extraArgs['path'] = path
- extraArgs['Vhuser'] = Vhuser
-
- background = ApplicationInstaller('ChangeStatusThemes', extraArgs)
- background.start()
-
- data_ret = {'status': 1, 'error_message': 'None'}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def CreateStagingNow(self, userID=None, data=None):
- try:
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- extraArgs = {}
- extraArgs['adminID'] = admin.pk
- extraArgs['StagingDomain'] = data['StagingDomain']
- extraArgs['StagingName'] = data['StagingName']
- extraArgs['WPid'] = data['WPid']
- extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
-
- wpsite = WPSites.objects.get(pk=data['WPid'])
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- background = ApplicationInstaller('CreateStagingNow', extraArgs)
- background.start()
-
- time.sleep(2)
-
- data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
- 'tempStatusPath': extraArgs['tempStatusPath']}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
-
- except BaseException as msg:
- data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def UpdateWPSettings(self, userID=None, data=None):
- try:
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- siteId = data['siteId']
- setting = data['setting']
- value = data['value']
-
- wpsite = WPSites.objects.get(pk=siteId)
-
- if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) != 1:
- return ACLManager.loadError()
-
# Get PHP version and path
Webobj = Websites.objects.get(pk=wpsite.owner_id)
Vhuser = Webobj.externalApp
@@ -4010,751 +1973,59 @@ Require valid-user"""
with open(htaccess, 'w') as f:
f.write(htaccess_content)
- def submitWebsiteModify(self, userID=None, data=None):
+ data_ret = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def GetWPSitesByDomain(self, userID=None, data=None):
try:
-
currentACL = ACLManager.loadedACL(userID)
- if ACLManager.currentContextPermission(currentACL, 'modifyWebsite') == 0:
- return ACLManager.loadErrorJson('modifyStatus', 0)
-
admin = Administrator.objects.get(pk=userID)
- if ACLManager.checkOwnership(data['websiteToBeModified'], admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadErrorJson('websiteDeleteStatus', 0)
-
- packs = ACLManager.loadPackages(userID, currentACL)
- admins = ACLManager.loadAllUsers(userID)
-
- ## Get packs name
-
- json_data = "["
- checker = 0
-
- for items in packs:
- dic = {"pack": items}
-
- if checker == 0:
- json_data = json_data + json.dumps(dic)
- checker = 1
- else:
- json_data = json_data + ',' + json.dumps(dic)
-
- json_data = json_data + ']'
-
- ### Get admin names
-
- admin_data = "["
- checker = 0
-
- for items in admins:
- dic = {"adminNames": items}
-
- if checker == 0:
- admin_data = admin_data + json.dumps(dic)
- checker = 1
- else:
- admin_data = admin_data + ',' + json.dumps(dic)
-
- admin_data = admin_data + ']'
-
- websiteToBeModified = data['websiteToBeModified']
-
- modifyWeb = Websites.objects.get(domain=websiteToBeModified)
-
- email = modifyWeb.adminEmail
- currentPack = modifyWeb.package.packageName
- owner = modifyWeb.admin.userName
-
- data_ret = {'status': 1, 'modifyStatus': 1, 'error_message': "None", "adminEmail": email,
- "packages": json_data, "current_pack": currentPack, "adminNames": admin_data,
- 'currentAdmin': owner}
- final_json = json.dumps(data_ret)
- return HttpResponse(final_json)
-
- except BaseException as msg:
- dic = {'status': 0, 'modifyStatus': 0, 'error_message': str(msg)}
- json_data = json.dumps(dic)
- return HttpResponse(json_data)
-
- def fetchWebsiteDataJSON(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- if ACLManager.currentContextPermission(currentACL, 'createWebsite') == 0:
- return ACLManager.loadErrorJson('createWebSiteStatus', 0)
-
- packs = ACLManager.loadPackages(userID, currentACL)
- admins = ACLManager.loadAllUsers(userID)
-
- ## Get packs name
-
- json_data = "["
- checker = 0
-
- for items in packs:
- dic = {"pack": items}
-
- if checker == 0:
- json_data = json_data + json.dumps(dic)
- checker = 1
- else:
- json_data = json_data + ',' + json.dumps(dic)
-
- json_data = json_data + ']'
-
- ### Get admin names
-
- admin_data = "["
- checker = 0
-
- for items in admins:
- dic = {"adminNames": items}
-
- if checker == 0:
- admin_data = admin_data + json.dumps(dic)
- checker = 1
- else:
- admin_data = admin_data + ',' + json.dumps(dic)
-
- admin_data = admin_data + ']'
-
- data_ret = {'status': 1, 'error_message': "None",
- "packages": json_data, "adminNames": admin_data}
- final_json = json.dumps(data_ret)
- return HttpResponse(final_json)
-
- except BaseException as msg:
- dic = {'status': 0, 'error_message': str(msg)}
- json_data = json.dumps(dic)
- return HttpResponse(json_data)
-
- def saveWebsiteChanges(self, userID=None, data=None):
- try:
+
domain = data['domain']
- package = data['packForWeb']
- email = data['email']
- phpVersion = data['phpVersion']
- newUser = data['admin']
-
- currentACL = ACLManager.loadedACL(userID)
- if ACLManager.currentContextPermission(currentACL, 'modifyWebsite') == 0:
- return ACLManager.loadErrorJson('saveStatus', 0)
-
- admin = Administrator.objects.get(pk=userID)
+ website = Websites.objects.get(domain=domain)
+
if ACLManager.checkOwnership(domain, admin, currentACL) == 1:
pass
else:
- return ACLManager.loadErrorJson('websiteDeleteStatus', 0)
-
- newOwner = Administrator.objects.get(userName=newUser)
- if ACLManager.checkUserOwnerShip(currentACL, admin, newOwner) == 1:
- pass
- else:
- return ACLManager.loadErrorJson('websiteDeleteStatus', 0)
-
- confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + domain
- completePathToConfigFile = confPath + "/vhost.conf"
-
- execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
- execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile
- ProcessUtilities.popenExecutioner(execPath)
-
- ####
-
- newOwner = Administrator.objects.get(userName=newUser)
-
- modifyWeb = Websites.objects.get(domain=domain)
- webpack = Package.objects.get(packageName=package)
-
- modifyWeb.package = webpack
- modifyWeb.adminEmail = email
- modifyWeb.phpSelection = phpVersion
- modifyWeb.admin = newOwner
-
- modifyWeb.save()
-
- ## Fix https://github.com/usmannasir/cyberpanel/issues/998
-
- # from plogical.IncScheduler import IncScheduler
- # isPU = IncScheduler('CalculateAndUpdateDiskUsage', {})
- # isPU.start()
-
- command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/IncScheduler.py UpdateDiskUsageForce'
- ProcessUtilities.outputExecutioner(command)
-
- ##
-
- data_ret = {'status': 1, 'saveStatus': 1, 'error_message': "None"}
+ return ACLManager.loadErrorJson('fetchStatus', 0)
+
+ # Get all WordPress sites for this website
+ wp_sites = []
+ for wp in website.wp_sites.all():
+ site_data = {
+ 'id': wp.id,
+ 'title': wp.title,
+ 'url': wp.url,
+ 'version': wp.version,
+ 'phpVersion': wp.phpVersion,
+ 'activePlugins': wp.activePlugins,
+ 'theme': wp.theme,
+ 'debugging': wp.debugging,
+ 'searchIndex': wp.searchIndex,
+ 'maintenanceMode': wp.maintenanceMode,
+ 'passwordProtection': wp.passwordProtection
+ }
+ wp_sites.append(site_data)
+
+ data_ret = {'status': 1, 'data': wp_sites}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except Websites.DoesNotExist:
+ data_ret = {'status': 0, 'error_message': 'Website not found'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
-
except BaseException as msg:
- data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)}
+ data_ret = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
- def loadDomainHome(self, request=None, userID=None, data=None):
-
- if Websites.objects.filter(domain=self.domain).exists():
-
- currentACL = ACLManager.loadedACL(userID)
- website = Websites.objects.get(domain=self.domain)
- admin = Administrator.objects.get(pk=userID)
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- Data = {}
-
- marketingStatus = emACL.checkIfEMEnabled(admin.userName)
-
- Data['marketingStatus'] = marketingStatus
- Data['ftpTotal'] = website.package.ftpAccounts
- Data['ftpUsed'] = website.users_set.all().count()
-
- Data['databasesUsed'] = website.databases_set.all().count()
- Data['databasesTotal'] = website.package.dataBases
-
- Data['domain'] = self.domain
-
- DiskUsage, DiskUsagePercentage, bwInMB, bwUsage = virtualHostUtilities.FindStats(website)
-
- ## bw usage calculations
-
- Data['bwInMBTotal'] = website.package.bandwidth
- Data['bwInMB'] = bwInMB
- Data['bwUsage'] = bwUsage
-
- if DiskUsagePercentage > 100:
- DiskUsagePercentage = 100
-
- Data['diskUsage'] = DiskUsagePercentage
- Data['diskInMB'] = DiskUsage
- Data['diskInMBTotal'] = website.package.diskSpace
-
- Data['phps'] = PHPManager.findPHPVersions()
-
- servicePath = '/home/cyberpanel/postfix'
- if os.path.exists(servicePath):
- Data['email'] = 1
- else:
- Data['email'] = 0
-
- ## Getting SSL Information
- try:
- import OpenSSL
- from datetime import datetime
- filePath = '/etc/letsencrypt/live/%s/fullchain.pem' % (self.domain)
- x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM,
- open(filePath, 'r').read())
- expireData = x509.get_notAfter().decode('ascii')
- finalDate = datetime.strptime(expireData, '%Y%m%d%H%M%SZ')
-
- now = datetime.now()
- diff = finalDate - now
- Data['viewSSL'] = 1
- Data['days'] = str(diff.days)
- Data['authority'] = x509.get_issuer().get_components()[1][1].decode('utf-8')
-
- if Data['authority'] == 'Denial':
- Data['authority'] = '%s has SELF-SIGNED SSL.' % (self.domain)
- else:
- Data['authority'] = '%s has SSL from %s.' % (self.domain, Data['authority'])
-
- except BaseException as msg:
- Data['viewSSL'] = 0
- logging.CyberCPLogFileWriter.writeToFile(str(msg))
-
- servicePath = '/home/cyberpanel/pureftpd'
- if os.path.exists(servicePath):
- Data['ftp'] = 1
- else:
- Data['ftp'] = 0
-
- proc = httpProc(request, 'websiteFunctions/website.html', Data)
- return proc.render()
- else:
- proc = httpProc(request, 'websiteFunctions/website.html',
- {"error": 1, "domain": "This domain does not exists."})
- return proc.render()
-
- def launchChild(self, request=None, userID=None, data=None):
-
- if ChildDomains.objects.filter(domain=self.childDomain).exists():
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadError()
-
- website = Websites.objects.get(domain=self.domain)
-
- Data = {}
-
- Data['ftpTotal'] = website.package.ftpAccounts
- Data['ftpUsed'] = website.users_set.all().count()
-
- Data['databasesUsed'] = website.databases_set.all().count()
- Data['databasesTotal'] = website.package.dataBases
-
- Data['domain'] = self.domain
- Data['childDomain'] = self.childDomain
-
- DiskUsage, DiskUsagePercentage, bwInMB, bwUsage = virtualHostUtilities.FindStats(website)
-
- ## bw usage calculations
-
- Data['bwInMBTotal'] = website.package.bandwidth
- Data['bwInMB'] = bwInMB
- Data['bwUsage'] = bwUsage
-
- if DiskUsagePercentage > 100:
- DiskUsagePercentage = 100
-
- Data['diskUsage'] = DiskUsagePercentage
- Data['diskInMB'] = DiskUsage
- Data['diskInMBTotal'] = website.package.diskSpace
-
- Data['phps'] = PHPManager.findPHPVersions()
-
- servicePath = '/home/cyberpanel/postfix'
- if os.path.exists(servicePath):
- Data['email'] = 1
- else:
- Data['email'] = 0
-
- servicePath = '/home/cyberpanel/pureftpd'
- if os.path.exists(servicePath):
- Data['ftp'] = 1
- else:
- Data['ftp'] = 0
-
- ## Getting SSL Information
- try:
- import OpenSSL
- from datetime import datetime
- filePath = '/etc/letsencrypt/live/%s/fullchain.pem' % (self.childDomain)
- x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM,
- open(filePath, 'r').read())
- expireData = x509.get_notAfter().decode('ascii')
- finalDate = datetime.strptime(expireData, '%Y%m%d%H%M%SZ')
-
- now = datetime.now()
- diff = finalDate - now
- Data['viewSSL'] = 1
- Data['days'] = str(diff.days)
- Data['authority'] = x509.get_issuer().get_components()[1][1].decode('utf-8')
-
- if Data['authority'] == 'Denial':
- Data['authority'] = '%s has SELF-SIGNED SSL.' % (self.childDomain)
- else:
- Data['authority'] = '%s has SSL from %s.' % (self.childDomain, Data['authority'])
-
- except BaseException as msg:
- Data['viewSSL'] = 0
- logging.CyberCPLogFileWriter.writeToFile(str(msg))
-
- proc = httpProc(request, 'websiteFunctions/launchChild.html', Data)
- return proc.render()
- else:
- proc = httpProc(request, 'websiteFunctions/launchChild.html',
- {"error": 1, "domain": "This child domain does not exists"})
- return proc.render()
-
- def getDataFromLogFile(self, userID=None, data=None):
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- logType = data['logType']
- self.domain = data['virtualHost']
- page = data['page']
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadErrorJson('logstatus', 0)
-
- if logType == 1:
- fileName = "/home/" + self.domain + "/logs/" + self.domain + ".access_log"
- else:
- fileName = "/home/" + self.domain + "/logs/" + self.domain + ".error_log"
-
- command = 'ls -la %s' % fileName
- result = ProcessUtilities.outputExecutioner(command)
-
- if result.find('->') > -1:
- final_json = json.dumps(
- {'status': 0, 'logstatus': 0,
- 'error_message': "Symlink attack."})
- return HttpResponse(final_json)
-
- ## get Logs
- website = Websites.objects.get(domain=self.domain)
-
- output = virtualHostUtilities.getAccessLogs(fileName, page, website.externalApp)
-
- if output.find("1,None") > -1:
- final_json = json.dumps(
- {'status': 0, 'logstatus': 0,
- 'error_message': "Not able to fetch logs, see CyberPanel main log file, Error: %s" % (output)})
- return HttpResponse(final_json)
-
- ## get log ends here.
-
- data = output.split("\n")
-
- json_data = "["
- checker = 0
-
- for items in reversed(data):
- if len(items) > 10:
- logData = items.split(" ")
- domain = logData[5].strip('"')
- ipAddress = logData[0].strip('"')
- time = (logData[3]).strip("[").strip("]")
- resource = logData[6].strip('"')
- size = logData[9].replace('"', '')
-
- dic = {'domain': domain,
- 'ipAddress': ipAddress,
- 'time': time,
- 'resource': resource,
- 'size': size,
- }
-
- if checker == 0:
- json_data = json_data + json.dumps(dic)
- checker = 1
- else:
- json_data = json_data + ',' + json.dumps(dic)
-
- json_data = json_data + ']'
- final_json = json.dumps({'status': 1, 'logstatus': 1, 'error_message': "None", "data": json_data})
- return HttpResponse(final_json)
-
- def fetchErrorLogs(self, userID=None, data=None):
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- self.domain = data['virtualHost']
- page = data['page']
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadErrorJson('logstatus', 0)
-
- fileName = "/home/" + self.domain + "/logs/" + self.domain + ".error_log"
-
- command = 'ls -la %s' % fileName
- result = ProcessUtilities.outputExecutioner(command)
-
- if result.find('->') > -1:
- final_json = json.dumps(
- {'status': 0, 'logstatus': 0,
- 'error_message': "Symlink attack."})
- return HttpResponse(final_json)
-
- ## get Logs
- website = Websites.objects.get(domain=self.domain)
-
- output = virtualHostUtilities.getErrorLogs(fileName, page, website.externalApp)
-
- if output.find("1,None") > -1:
- final_json = json.dumps(
- {'status': 0, 'logstatus': 0, 'error_message': "Not able to fetch logs, see CyberPanel main log file!"})
- return HttpResponse(final_json)
-
- ## get log ends here.
-
- final_json = json.dumps({'status': 1, 'logstatus': 1, 'error_message': "None", "data": output})
- return HttpResponse(final_json)
-
- def getDataFromConfigFile(self, userID=None, data=None):
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- self.domain = data['virtualHost']
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadErrorJson('configstatus', 0)
-
- command = 'cat %s' % ('/usr/local/lsws/conf/dvhost_redis.conf')
-
- if ProcessUtilities.outputExecutioner(command).find('127.0.0.1') == -1:
- filePath = installUtilities.Server_root_path + "/conf/vhosts/" + self.domain + "/vhost.conf"
-
- command = 'cat ' + filePath
- configData = ProcessUtilities.outputExecutioner(command, 'lsadm')
-
- if len(configData) == 0:
- status = {'status': 0, "configstatus": 0, "error_message": "Configuration file is currently empty!"}
-
- final_json = json.dumps(status)
- return HttpResponse(final_json)
-
- else:
- command = 'redis-cli get "vhost:%s"' % (self.domain)
- configData = ProcessUtilities.outputExecutioner(command)
- configData = '#### This configuration is fetched from redis as Redis-Mass Hosting is being used.\n%s' % (
- configData)
-
- status = {'status': 1, "configstatus": 1, "configData": configData}
- final_json = json.dumps(status)
- return HttpResponse(final_json)
-
- def saveConfigsToFile(self, userID=None, data=None):
-
- currentACL = ACLManager.loadedACL(userID)
-
- if currentACL['admin'] != 1:
- return ACLManager.loadErrorJson('configstatus', 0)
-
- configData = data['configData']
- self.domain = data['virtualHost']
-
- if len(configData) == 0:
- status = {"configstatus": 0, 'error_message': 'Error: you are trying to save empty vhost file, your website will stop working.'}
-
- final_json = json.dumps(status)
- return HttpResponse(final_json)
-
-
- command = 'cat %s' % ('/usr/local/lsws/conf/dvhost_redis.conf')
-
- if ProcessUtilities.outputExecutioner(command).find('127.0.0.1') == -1:
-
- mailUtilities.checkHome()
-
- tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
-
- vhost = open(tempPath, "w")
-
- vhost.write(configData)
-
- vhost.close()
-
- ## writing data temporary to file
-
- filePath = installUtilities.Server_root_path + "/conf/vhosts/" + self.domain + "/vhost.conf"
-
- ## save configuration data
-
- execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
- execPath = execPath + " saveVHostConfigs --path " + filePath + " --tempPath " + tempPath
-
- output = ProcessUtilities.outputExecutioner(execPath)
-
- if output.find("1,None") > -1:
- status = {"configstatus": 1}
-
- final_json = json.dumps(status)
- return HttpResponse(final_json)
- else:
- data_ret = {'configstatus': 0, 'error_message': output}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- ## save configuration data ends
- else:
- command = "redis-cli set vhost:%s '%s'" % (self.domain, configData.replace(
- '#### This configuration is fetched from redis as Redis-Mass Hosting is being used.\n', ''))
- ProcessUtilities.executioner(command)
-
- status = {"configstatus": 1}
-
- final_json = json.dumps(status)
- return HttpResponse(final_json)
-
- def getRewriteRules(self, userID=None, data=None):
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- self.domain = data['virtualHost']
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadErrorJson('rewriteStatus', 0)
-
- try:
- childDom = ChildDomains.objects.get(domain=self.domain)
- filePath = childDom.path + '/.htaccess'
- externalApp = childDom.master.externalApp
- except:
- website = Websites.objects.get(domain=self.domain)
- externalApp = website.externalApp
- filePath = "/home/" + self.domain + "/public_html/.htaccess"
-
- try:
- command = 'cat %s' % (filePath)
- rewriteRules = ProcessUtilities.outputExecutioner(command, externalApp)
-
- if len(rewriteRules) == 0:
- status = {"rewriteStatus": 1, "error_message": "Rules file is currently empty"}
- final_json = json.dumps(status)
- return HttpResponse(final_json)
-
- status = {"rewriteStatus": 1, "rewriteRules": rewriteRules}
-
- final_json = json.dumps(status)
- return HttpResponse(final_json)
-
- except BaseException as msg:
- status = {"rewriteStatus": 1, "error_message": str(msg), "rewriteRules": ""}
- final_json = json.dumps(status)
- return HttpResponse(final_json)
-
- def saveRewriteRules(self, userID=None, data=None):
- try:
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- self.domain = data['virtualHost']
- rewriteRules = data['rewriteRules'].encode('utf-8')
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadErrorJson('rewriteStatus', 0)
-
- ## writing data temporary to file
-
- mailUtilities.checkHome()
- tempPath = "/tmp/" + str(randint(1000, 9999))
- vhost = open(tempPath, "wb")
- vhost.write(rewriteRules)
- vhost.close()
-
- ## writing data temporary to file
-
- try:
- childDomain = ChildDomains.objects.get(domain=self.domain)
- filePath = childDomain.path + '/.htaccess'
- externalApp = childDomain.master.externalApp
- except:
- filePath = "/home/" + self.domain + "/public_html/.htaccess"
- website = Websites.objects.get(domain=self.domain)
- externalApp = website.externalApp
-
- ## save configuration data
-
- command = 'cp %s %s' % (tempPath, filePath)
- ProcessUtilities.executioner(command, externalApp)
-
- command = 'rm -f %s' % (tempPath)
- ProcessUtilities.executioner(command, 'cyberpanel')
-
- installUtilities.reStartLiteSpeedSocket()
- status = {"rewriteStatus": 1, 'error_message': 'None'}
- final_json = json.dumps(status)
- return HttpResponse(final_json)
- except BaseException as msg:
- status = {"rewriteStatus": 0, 'error_message': str(msg)}
- final_json = json.dumps(status)
- return HttpResponse(final_json)
-
- def saveSSL(self, userID=None, data=None):
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- self.domain = data['virtualHost']
- key = data['key']
- cert = data['cert']
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadErrorJson('sslStatus', 0)
-
- mailUtilities.checkHome()
-
- ## writing data temporary to file
-
- tempKeyPath = "/home/cyberpanel/" + str(randint(1000, 9999))
- vhost = open(tempKeyPath, "w")
- vhost.write(key)
- vhost.close()
-
- tempCertPath = "/home/cyberpanel/" + str(randint(1000, 9999))
- vhost = open(tempCertPath, "w")
- vhost.write(cert)
- vhost.close()
-
- ## writing data temporary to file
-
- execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
- execPath = execPath + " saveSSL --virtualHostName " + self.domain + " --tempKeyPath " + tempKeyPath + " --tempCertPath " + tempCertPath
- output = ProcessUtilities.outputExecutioner(execPath)
-
- if output.find("1,None") > -1:
- data_ret = {'sslStatus': 1, 'error_message': "None"}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
- else:
- logging.CyberCPLogFileWriter.writeToFile(
- output)
- data_ret = {'sslStatus': 0, 'error_message': output}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
- def changePHP(self, userID=None, data=None):
-
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
- self.domain = data['childDomain']
- phpVersion = data['phpSelection']
-
- if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
- pass
- else:
- return ACLManager.loadErrorJson('changePHP', 0)
-
- confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + self.domain
- completePathToConfigFile = confPath + "/vhost.conf"
-
- execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
- execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile
- ProcessUtilities.popenExecutioner(execPath)
-
- try:
- website = Websites.objects.get(domain=self.domain)
- website.phpSelection = data['phpSelection']
- website.save()
-
- ### check if there are any alias domains under the main website and then change php for them too
-
- for alias in website.childdomains_set.filter(alais=1):
-
- try:
-
- confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + alias.domain
- completePathToConfigFile = confPath + "/vhost.conf"
- execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
- execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile
- ProcessUtilities.popenExecutioner(execPath)
- except BaseException as msg:
- logging.CyberCPLogFileWriter.writeToFile(f'Error changing PHP for alias: {str(msg)}')
-
-
- except:
- website = ChildDomains.objects.get(domain=self.domain)
- website.phpSelection = data['phpSelection']
- website.save()
-
- data_ret = {'status': 1, 'changePHP': 1, 'error_message': "None"}
- json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
-
def getWebsiteCron(self, userID=None, data=None):
try: