diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 4774bc9f8..0f0c34537 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -74,6 +74,7 @@ + {% with version="2.3.2.2" %} diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index 35401ce35..66210733c 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -18,6 +18,7 @@ function getCookie(name) { return cookieValue; } + var arry = [] function selectpluginJs(val) { @@ -252,6 +253,28 @@ app.controller('WPAddNewPlugin', function ($scope, $http, $timeout, $window, $co }); +var domain_check = 0; + +function checkbox_function() { + + var checkBox = document.getElementById("myCheck"); + // Get the output text + + + // If the checkbox is checked, display the output text + if (checkBox.checked == true) { + domain_check = 0; + document.getElementById('Test_Domain').style.display = "block"; + document.getElementById('Own_Domain').style.display = "none"; + + } else { + document.getElementById('Test_Domain').style.display = "none"; + document.getElementById('Own_Domain').style.display = "block"; + domain_check = 1; + } + + // alert(domain_check); +} app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $window) { $scope.webSiteCreationLoading = true; @@ -262,6 +285,7 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $ $scope.couldNotConnect = true; $scope.goBackDisable = true; + var statusFile; $scope.createWordPresssite = function () { @@ -280,7 +304,17 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $ var package = $scope.packageForWebsite; var websiteOwner = $scope.websiteOwner; var WPtitle = $scope.WPtitle; - var domainNameCreate = $scope.domainNameCreate; + + if (domain_check == 0) { + var Part2_domainNameCreate = document.getElementById('Part2_domainNameCreate').value; + var domainNameCreate = document.getElementById('TestDomainNameCreate').value + Part2_domainNameCreate; + } + if (domain_check == 1) { + + var domainNameCreate = $scope.own_domainNameCreate; + } + + var WPUsername = $scope.WPUsername; var adminEmail = $scope.adminEmail; var WPPassword = $scope.WPPassword; @@ -290,7 +324,17 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $ var pluginupdates = $scope.pluginupdates; var themeupdates = $scope.themeupdates; - var path = $scope.installPath; + if (domain_check == 0) { + + var path = ""; + + } + if (domain_check = 1) { + + var path = $scope.installPath; + + } + var home = "1"; @@ -298,6 +342,7 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $ home = "0"; } + //alert(domainNameCreate); var data = { title: WPtitle, @@ -315,6 +360,7 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $ home: home, path: path, } + var config = { headers: { 'X-CSRFToken': getCookie('csrftoken') @@ -461,6 +507,29 @@ function DeployToProductionInitial(vall) { DeploytoProductionID = vall; } +var create_staging_domain_check = 0; + +function create_staging_checkbox_function() { + + var checkBox = document.getElementById("Create_Staging_Check"); + // Get the output text + + + // If the checkbox is checked, display the output text + if (checkBox.checked == true) { + create_staging_domain_check = 0; + document.getElementById('Website_Create_Test_Domain').style.display = "block"; + document.getElementById('Website_Create_Own_Domain').style.display = "none"; + + } else { + document.getElementById('Website_Create_Test_Domain').style.display = "none"; + document.getElementById('Website_Create_Own_Domain').style.display = "block"; + create_staging_domain_check = 1; + } + + // alert(domain_check); +} + app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $window) { var CheckBoxpasssword = 0; @@ -1141,9 +1210,19 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo $scope.currentStatus = "Starting creation Staging.."; + + //here enter domain name + if (create_staging_domain_check == 0) { + var Part2_domainNameCreate = document.getElementById('Part2_domainNameCreate').value; + var domainNameCreate = document.getElementById('TestDomainNameCreate').value + Part2_domainNameCreate; + } + if (create_staging_domain_check == 1) { + + var domainNameCreate = $scope.own_domainNameCreate; + } var data = { StagingName: $('#stagingName').val(), - StagingDomain: $('#stagingDomain').val(), + StagingDomain: domainNameCreate, WPid: $('#WPid').html(), } var url = "/websites/CreateStagingNow"; @@ -2278,6 +2357,30 @@ app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) { }; }); /* Java script code to create account */ + +var website_create_domain_check = 0; + +function website_create_checkbox_function() { + + var checkBox = document.getElementById("myCheck"); + // Get the output text + + + // If the checkbox is checked, display the output text + if (checkBox.checked == true) { + website_create_domain_check = 0; + document.getElementById('Website_Create_Test_Domain').style.display = "block"; + document.getElementById('Website_Create_Own_Domain').style.display = "none"; + + } else { + document.getElementById('Website_Create_Test_Domain').style.display = "none"; + document.getElementById('Website_Create_Own_Domain').style.display = "block"; + website_create_domain_check = 1; + } + + // alert(domain_check); +} + app.controller('createWebsite', function ($scope, $http, $timeout, $window) { $scope.webSiteCreationLoading = true; @@ -2332,7 +2435,18 @@ app.controller('createWebsite', function ($scope, $http, $timeout, $window) { url = "/websites/submitWebsiteCreation"; var package = $scope.packageForWebsite; - var domainName = $scope.domainNameCreate; + + if (website_create_domain_check == 0) { + var Part2_domainNameCreate = document.getElementById('Part2_domainNameCreate').value; + var domainName = document.getElementById('TestDomainNameCreate').value + Part2_domainNameCreate; + } + if (website_create_domain_check == 1) { + + var domainName = $scope.own_domainNameCreate; + } + + // var domainName = $scope.domainNameCreate; + var adminEmail = $scope.adminEmail; var phpSelection = $scope.phpSelection; var websiteOwner = $scope.websiteOwner; @@ -2647,9 +2761,7 @@ app.controller('listWebsites', function ($scope, $http) { var url = "/websites/ScanWordpressSite"; - var data = { - - } + var data = {} var config = { @@ -3302,6 +3414,28 @@ app.controller('modifyWebsitesController', function ($scope, $http) { /* Java script code to create account */ +var website_child_domain_check = 0; + +function website_child_domain_checkbox_function() { + + var checkBox = document.getElementById("myCheck"); + // Get the output text + + + // If the checkbox is checked, display the output text + if (checkBox.checked == true) { + website_child_domain_check = 0; + document.getElementById('Website_Create_Test_Domain').style.display = "block"; + document.getElementById('Website_Create_Own_Domain').style.display = "none"; + + } else { + document.getElementById('Website_Create_Test_Domain').style.display = "none"; + document.getElementById('Website_Create_Own_Domain').style.display = "block"; + website_child_domain_check = 1; + } + + // alert(domain_check); +} app.controller('websitePages', function ($scope, $http, $timeout, $window) { @@ -4406,6 +4540,16 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) { if (typeof path === 'undefined') { path = ""; } + var package = $scope.packageForWebsite; + + if (website_child_domain_check == 0) { + var Part2_domainNameCreate = document.getElementById('Part2_domainNameCreate').value; + var domainName = document.getElementById('TestDomainNameCreate').value + Part2_domainNameCreate; + } + if (website_child_domain_check == 1) { + + var domainName = $scope.own_domainNameCreate; + } var data = { @@ -5084,7 +5228,7 @@ RewriteRule ^/(xmlrpc|wp-trackback)\.php - [F,L,NC] $scope.rewriteRules = nonWWWToWWW + $scope.rewriteRules; } else if ($scope.rewriteTemplate === "Force WWW -> NON-WWW") { $scope.rewriteRules = WWWToNonWWW + $scope.rewriteRules; - } else if ($scope.rewriteTemplate === "Disable Wordpress XMLRPC & Trackback") { + } else if ($scope.rewriteTemplate === "Disable Wordpress XMLRPC & Trackback") { $scope.rewriteRules = WordpressProtect + $scope.rewriteRules; } }; diff --git a/websiteFunctions/templates/websiteFunctions/WPCreate.html b/websiteFunctions/templates/websiteFunctions/WPCreate.html index fe6c8e6ba..b32c5b86c 100644 --- a/websiteFunctions/templates/websiteFunctions/WPCreate.html +++ b/websiteFunctions/templates/websiteFunctions/WPCreate.html @@ -6,6 +6,88 @@ {% load static %} {% get_current_language as LANGUAGE_CODE %} +
@@ -54,40 +136,115 @@
-{#
#} -{# #} -{#
#} -{# #} -{#
#} -{#
{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}
#} -{#
#} + {#
#} + {# #} + {#
#} + {# #} + {#
#} + {#
{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}
#} + {#
#} + + {# My Work #}
- -
-
+ + + + + + +

+ + +
+
+ +
+
- - / - + + + + +
+
+
{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}
+
+
+
Looks like you have not subscripted to temporary domain feature,click here + for more details. +
+
+
+ +
-
{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}
+
- - + {# My Work End#} + {# #}
diff --git a/websiteFunctions/templates/websiteFunctions/WPsiteHome.html b/websiteFunctions/templates/websiteFunctions/WPsiteHome.html index c66d4e1a1..2dd80c57c 100644 --- a/websiteFunctions/templates/websiteFunctions/WPsiteHome.html +++ b/websiteFunctions/templates/websiteFunctions/WPsiteHome.html @@ -7,6 +7,92 @@ {% get_current_language as LANGUAGE_CODE %} + + + + @@ -304,17 +390,107 @@ type="text" class="form-control" id="stagingName">
-
- -
- +
+ +
+ + + + + +

+ + +
+
+ +
+
+ + + + + +
+
+
{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}
+
+
+
Looks like you have not subscripted to temporary domain feature, + click here + for more details. +
+
+
+ + +
-
+{# end my work#} +
+ {# My Work End #} +
diff --git a/websiteFunctions/templates/websiteFunctions/createWebsite.html b/websiteFunctions/templates/websiteFunctions/createWebsite.html index 5c6403205..a6c2ebba3 100755 --- a/websiteFunctions/templates/websiteFunctions/createWebsite.html +++ b/websiteFunctions/templates/websiteFunctions/createWebsite.html @@ -6,6 +6,89 @@ {% load static %} {% get_current_language as LANGUAGE_CODE %} +
@@ -47,15 +130,98 @@
+ {# My Work #}
- -
- + + + + + +

+ + +
+
+ +
+
+ + + + + +
+
+
{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}
+
+
+
Looks like you have not subscripted to temporary domain feature, click here + for more details. +
+
-
{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}
+ + +
+ {# My Work End#} + {# #}
diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index e188f09ce..13a3214b0 100755 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -33,7 +33,7 @@ def WPCreate(request): try: userID = request.session['userID'] wm = WebsiteManager() - return wm.WPCreate(request, userID) + return wm.WPCreate(request, userID,) except KeyError: return redirect(loadLoginPage) diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 62e8558e8..9edb94b3e 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -14,7 +14,8 @@ django.setup() import json from plogical.acl import ACLManager import plogical.CyberCPLogFileWriter as logging -from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging, WPSitesBackup, RemoteBackupConfig,RemoteBackupSchedule, RemoteBackupsites +from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging, WPSitesBackup, \ + RemoteBackupConfig, RemoteBackupSchedule, RemoteBackupsites from plogical.virtualHostUtilities import virtualHostUtilities import subprocess import shlex @@ -52,12 +53,26 @@ class WebsiteManager: self.childDomain = childDomain def createWebsite(self, request=None, userID=None, data=None): + url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission" + + test_domain_data = { + "name": "test-domain", + "IP": ACLManager.GetServerIP(), + } + + import requests + response = requests.post(url, data=json.dumps(test_domain_data)) + test_domain_status = response.json()['status'] + currentACL = ACLManager.loadedACL(userID) adminNames = ACLManager.loadAllUsers(userID) packagesName = ACLManager.loadPackages(userID, currentACL) phps = PHPManager.findPHPVersions() - Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps} + 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() @@ -82,7 +97,8 @@ class WebsiteManager: counter = 0 try: import requests - WPVersions = json.loads(requests.get('https://api.wordpress.org/core/version-check/1.7/').text)['offers'] + WPVersions = json.loads(requests.get('https://api.wordpress.org/core/version-check/1.7/').text)[ + 'offers'] for versions in WPVersions: if counter == 7: @@ -94,8 +110,21 @@ class WebsiteManager: FinalVersions = ['5.6', '5.5.3', '5.5.2'] Plugins = wpplugins.objects.filter(owner=userobj) + rnpss = randomPassword.generate_pass(10) - Data = {'packageList': packagesName, "owernList": adminNames, 'WPVersions': FinalVersions, 'Plugins': Plugins } + ## + + test_domain_data = { + "name": "test-domain", + "IP": ACLManager.GetServerIP(), + } + + import requests + response = requests.post(url, data=json.dumps(test_domain_data)) + test_domain_status = response.json()['status'] + + 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, 'createWebsite') return proc.render() @@ -108,8 +137,8 @@ class WebsiteManager: admin = Administrator.objects.get(pk=userID) tata = {} - tata['wp']=[] - tata['wpsites']=[] + tata['wp'] = [] + tata['wpsites'] = [] tata['wp'] = ACLManager.GetALLWPObjects(currentACL, userID) try: @@ -155,6 +184,22 @@ class WebsiteManager: response = requests.post(url, data=json.dumps(data)) Status = response.json()['status'] + test_domain_url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission" + + test_domain_data = { + "name": "test-domain", + "IP": ACLManager.GetServerIP(), + } + + import requests + response = requests.post(test_domain_url, data=json.dumps(test_domain_data)) + test_domain_status = response.json()['status'] + Data['test_domain_data'] = test_domain_status + + rnpss = randomPassword.generate_pass(10) + + Data['Randam_String'] = rnpss.lower() + if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent: Data['wpsite'] = WPobj @@ -166,7 +211,7 @@ class WebsiteManager: wstagingDelete.delete() except BaseException as msg: - da= str(msg) + da = str(msg) proc = httpProc(request, 'websiteFunctions/WPsiteHome.html', Data, 'createWebsite') @@ -179,7 +224,7 @@ class WebsiteManager: Data, 'createWebsite') return proc.render() - def RestoreHome(self, request=None, userID=None, BackupID=None ): + def RestoreHome(self, request=None, userID=None, BackupID=None): Data = {} currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) @@ -194,9 +239,9 @@ class WebsiteManager: return ACLManager.loadError() config = json.loads(Data['backupobj'].config) - Data['FileName']= config['name'] + Data['FileName'] = config['name'] try: - Data['Backuptype']= config['Backuptype'] + Data['Backuptype'] = config['Backuptype'] except: Data['Backuptype'] = None Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID) @@ -207,7 +252,7 @@ class WebsiteManager: from django.shortcuts import reverse return redirect(reverse('pricing')) - def RemoteBackupConfig(self, request=None, userID=None, DeleteID=None ): + def RemoteBackupConfig(self, request=None, userID=None, DeleteID=None): Data = {} currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) @@ -222,7 +267,7 @@ class WebsiteManager: Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID) allcon = RemoteBackupConfig.objects.all() - Data['backupconfigs'] =[] + Data['backupconfigs'] = [] for i in allcon: configr = json.loads(i.config) if i.configtype == "SFTP": @@ -256,8 +301,7 @@ class WebsiteManager: from django.shortcuts import reverse return redirect(reverse('pricing')) - - def BackupfileConfig(self, request=None, userID=None, RemoteConfigID=None, DeleteID=None ): + def BackupfileConfig(self, request=None, userID=None, RemoteConfigID=None, DeleteID=None): Data = {} currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) @@ -293,14 +337,13 @@ class WebsiteManager: from django.shortcuts import reverse return redirect(reverse('pricing')) - - def AddRemoteBackupsite(self, request=None, userID=None, RemoteScheduleID=None , DeleteSiteID=None): + 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) + RemoteBackupScheduleobj = RemoteBackupSchedule.objects.get(pk=RemoteScheduleID) try: if DeleteSiteID != None: @@ -329,9 +372,8 @@ class WebsiteManager: from django.shortcuts import reverse return redirect(reverse('pricing')) - - def WordpressPricing(self, request=None, userID=None,): - Data ={} + def WordpressPricing(self, request=None, userID=None, ): + Data = {} proc = httpProc(request, 'websiteFunctions/CyberpanelPricing.html', Data, 'createWebsite') return proc.render() @@ -364,11 +406,10 @@ class WebsiteManager: 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 + command = "rm -r /home/backup/%s.tar.gz" % FileName ProcessUtilities.executioner(command) DeleteIDobj.delete() @@ -391,7 +432,6 @@ class WebsiteManager: except: Backuptype = "Backup type not exists" - Data['job'].append({ 'id': sub.id, 'title': web, @@ -399,7 +439,6 @@ class WebsiteManager: 'BackupDestination': BackupDestination }) - proc = httpProc(request, 'websiteFunctions/RestoreBackups.html', Data, 'createWebsite') return proc.render() @@ -419,8 +458,8 @@ class WebsiteManager: else: return ACLManager.loadError() - #php = VirtualHost.getPHPString(self.data['PHPVersion']) - #FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php) + # php = VirtualHost.getPHPString(self.data['PHPVersion']) + # FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php) url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission" data = { @@ -438,10 +477,12 @@ class WebsiteManager: password = randomPassword.generate_pass(10) - command = 'sudo -u %s 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) + command = 'sudo -u %s 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 = 'sudo -u %s wp user update autologin --user_pass="%s" --path=%s --skip-plugins --skip-themes' % (WPobj.owner.externalApp, password, WPobj.path) + command = 'sudo -u %s wp user update autologin --user_pass="%s" --path=%s --skip-plugins --skip-themes' % ( + WPobj.owner.externalApp, password, WPobj.path) ProcessUtilities.executioner(command) data = {} @@ -468,11 +509,10 @@ class WebsiteManager: currentACL = ACLManager.loadedACL(userID) userobj = Administrator.objects.get(pk=userID) + Selectedplugins = wpplugins.objects.filter(owner=userobj) + # data['Selectedplugins'] = wpplugins.objects.filter(ProjectOwner=HostingCompany) - Selectedplugins = wpplugins.objects.filter(owner = userobj) - #data['Selectedplugins'] = wpplugins.objects.filter(ProjectOwner=HostingCompany) - - Data = {'Selectedplugins' : Selectedplugins,} + Data = {'Selectedplugins': Selectedplugins, } proc = httpProc(request, 'websiteFunctions/WPConfigurePlugins.html', Data, 'createWebsite') return proc.render() @@ -495,8 +535,6 @@ class WebsiteManager: return redirect(reverse('pricing')) - - def SearchOnkeyupPlugin(self, userID=None, data=None): try: if ACLManager.CheckForPremFeature('wp-manager'): @@ -505,7 +543,8 @@ class WebsiteManager: 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) + url = "http://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[search]=%s" % str( + pluginname) import requests res = requests.get(url) @@ -513,7 +552,7 @@ class WebsiteManager: # return proc.ajax(1, 'Done', {'plugins': r}) - data_ret = {'status': 1,'plugns': r,} + data_ret = {'status': 1, 'plugns': r, } json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -539,7 +578,6 @@ class WebsiteManager: # logging.CyberCPLogFileWriter.writeToFile("config ....... %s"%config) # logging.CyberCPLogFileWriter.writeToFile(" Name ....... %s"%Name) - addpl = wpplugins(Name=Name, config=json.dumps(config), owner=userobj) addpl.save() @@ -553,8 +591,8 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - def EidtPlugin(self,request=None, userID=None, pluginbID=None): - 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) @@ -569,12 +607,11 @@ class WebsiteManager: Data['pluginbID'] = pluginbID Data['BucketName'] = pluginobj.Name - proc = httpProc(request, 'websiteFunctions/WPEidtPlugin.html', Data, 'createWebsite') return proc.render() - def deletesPlgin(self, userID=None, data=None,): + def deletesPlgin(self, userID=None, data=None, ): try: currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) @@ -606,7 +643,7 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - def Addplugineidt(self, userID=None, data=None,): + def Addplugineidt(self, userID=None, data=None, ): try: currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) @@ -614,8 +651,8 @@ class WebsiteManager: pluginname = data['pluginname'] pluginbBucketID = data['pluginbBucketID'] - #logging.CyberCPLogFileWriter.writeToFile("pluginbID ....... %s" % pluginbBucketID) - #logging.CyberCPLogFileWriter.writeToFile("pluginname ....... %s" % pluginname) + # logging.CyberCPLogFileWriter.writeToFile("pluginbID ....... %s" % pluginbBucketID) + # logging.CyberCPLogFileWriter.writeToFile("pluginname ....... %s" % pluginname) pObj = wpplugins.objects.get(pk=pluginbBucketID, owner=userobj) @@ -640,7 +677,6 @@ class WebsiteManager: pObj.config = json.dumps(ab) pObj.save() - data_ret = {'status': 1} json_data = json.dumps(data_ret) @@ -669,8 +705,21 @@ class WebsiteManager: def CreateNewDomain(self, request=None, userID=None, data=None): currentACL = ACLManager.loadedACL(userID) websitesName = ACLManager.findAllSites(currentACL, userID) + + test_domain_url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission" + + test_domain_data = { + "name": "test-domain", + "IP": ACLManager.GetServerIP(), + } + + import requests + response = requests.post(test_domain_url, data=json.dumps(test_domain_data)) + test_domain_status = response.json()['status'] + + rnpss = randomPassword.generate_pass(10) proc = httpProc(request, 'websiteFunctions/createDomain.html', - {'websiteList': websitesName, 'phps': PHPManager.findPHPVersions()}) + {'websiteList': websitesName, 'phps': PHPManager.findPHPVersions(), 'Randam_String': rnpss, 'test_domain_data':test_domain_status}) return proc.render() def siteState(self, request=None, userID=None, data=None): @@ -750,7 +799,7 @@ class WebsiteManager: path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + Webobj = Websites.objects.get(pk=wpsite.owner_id) Vhuser = Webobj.externalApp PHPVersion = Webobj.phpSelection @@ -758,13 +807,13 @@ class WebsiteManager: 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' % (Vhuser, FinalPHPPath, path) + command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s' % ( + Vhuser, FinalPHPPath, path) version = ProcessUtilities.outputExecutioner(command) 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) + 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: @@ -772,8 +821,8 @@ class WebsiteManager: 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) + 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'): @@ -781,13 +830,13 @@ class WebsiteManager: 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) + 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) + 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] @@ -796,7 +845,6 @@ class WebsiteManager: else: maintenanceMode = 1 - ##### Check passwd protection vhostName = wpsite.owner.domain vhostPassDir = f'/home/{vhostName}' @@ -806,16 +854,15 @@ class WebsiteManager: else: passwd = 0 - #### Check WP cron - command = "sudo -u %s cat %s/wp-config.php"%(Vhuser, wpsite.path) + 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 ={ + fb = { 'version': version.rstrip('\n'), 'lscache': lscache, 'debugging': debugging, @@ -826,7 +873,7 @@ class WebsiteManager: } - data_ret = {'status': 1, 'error_message': 'None', 'ret_data':fb} + data_ret = {'status': 1, 'error_message': 'None', 'ret_data': fb} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -852,18 +899,18 @@ class WebsiteManager: path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + 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) + 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) @@ -890,20 +937,18 @@ class WebsiteManager: path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + 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) + 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) @@ -930,10 +975,8 @@ class WebsiteManager: 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) @@ -977,7 +1020,7 @@ class WebsiteManager: if stdoutput.find('Error:') == -1: DataBaseUser = stdoutput.rstrip("\n") - DataBaseUser = html.escape(DataBaseUser) + DataBaseUser = html.escape(DataBaseUser) else: data_ret = {'status': 0, 'error_message': stdoutput} json_data = json.dumps(data_ret) @@ -988,13 +1031,14 @@ class WebsiteManager: if stdoutput.find('Error:') == -1: tableprefix = stdoutput.rstrip("\n") - tableprefix = html.escape(tableprefix) + 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} + data_ret = {'status': 1, 'error_message': 'None', "DataBaseUser": DataBaseUser, + "DataBaseName": DataBaseName, 'tableprefix': tableprefix} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1026,7 +1070,7 @@ class WebsiteManager: wpsite.ThemeUpdates = Themes wpsite.save() - data_ret = {'status': 1, 'error_message': 'None',} + data_ret = {'status': 1, 'error_message': 'None', } json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1092,7 +1136,6 @@ class WebsiteManager: wpsite = WPSites.objects.get(pk=WPManagerID) - if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1: pass else: @@ -1104,7 +1147,6 @@ class WebsiteManager: extraArgs['Backuptype'] = Backuptype extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) - background = ApplicationInstaller('WPCreateBackup', extraArgs) background.start() @@ -1129,7 +1171,6 @@ class WebsiteManager: backupid = data['backupid'] DesSiteID = data['DesSite'] - # try: # # bwp = WPSites.objects.get(pk=int(backupid)) @@ -1148,10 +1189,8 @@ class WebsiteManager: # else: # return ACLManager.loadError() - Domain = data['Domain'] - extraArgs = {} extraArgs['adminID'] = admin.pk extraArgs['backupid'] = backupid @@ -1161,7 +1200,6 @@ class WebsiteManager: extraArgs['home'] = data['home'] extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) - background = ApplicationInstaller('RestoreWPbackupNow', extraArgs) background.start() @@ -1177,8 +1215,6 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - - def SaveBackupConfig(self, userID=None, data=None): try: @@ -1223,24 +1259,20 @@ class WebsiteManager: } - - mkobj = RemoteBackupConfig(owner=admin, configtype=ConfigType, config=json.dumps(config)) mkobj.save() - time.sleep(1) - data_ret = {'status': 1, 'error_message': '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)} + 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: @@ -1252,7 +1284,6 @@ class WebsiteManager: RemoteConfigID = data['RemoteConfigID'] BackupType = data['BackupType'] - RemoteBackupConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID) Rconfig = json.loads(RemoteBackupConfigobj.config) provider = Rconfig['Provider'] @@ -1282,31 +1313,31 @@ class WebsiteManager: 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) + 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 } - svobj = RemoteBackupSchedule( RemoteBackupConfig=RemoteBackupConfigobj, Name=ScheduleName, - timeintervel=Backfrequency, fileretention=FileRetention, config=json.dumps(config), - lastrun=str(time.time())) + 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',} + 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)} + 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: @@ -1340,19 +1371,18 @@ class WebsiteManager: raise BaseException(str("DataBase Not Found")) RemoteScheduleIDobj = RemoteBackupSchedule.objects.get(pk=RemoteScheduleID) - svobj = RemoteBackupsites( owner=RemoteScheduleIDobj, WPsites = WPid, database = DBobj.pk) + svobj = RemoteBackupsites(owner=RemoteScheduleIDobj, WPsites=WPid, database=DBobj.pk) svobj.save() - data_ret = {'status': 1, 'error_message': '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)} + 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: @@ -1367,16 +1397,15 @@ class WebsiteManager: scheduleobj.fileretention = FileRetention scheduleobj.save() - data_ret = {'status': 1, 'error_message': '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)} + 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: @@ -1404,7 +1433,7 @@ class WebsiteManager: for chlid in childdomain: childPath = chlid.path.rstrip('/') - command = "cat %s/wp-config.php"% childPath + command = "cat %s/wp-config.php" % childPath result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) if result == 1: @@ -1418,20 +1447,15 @@ class WebsiteManager: ThemeUpdates="Enabled", ) wpobj.save() - - - - data_ret = {'status': 1, 'error_message': '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)} + 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: @@ -1459,7 +1483,7 @@ class WebsiteManager: ###fetch WP version command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s' % ( - Vhuser, FinalPHPPath, path) + Vhuser, FinalPHPPath, path) version = ProcessUtilities.outputExecutioner(command) version = version.rstrip("\n") @@ -1467,7 +1491,6 @@ class WebsiteManager: 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) @@ -1477,7 +1500,6 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - def dataintegrity(self, userID=None, data=None): try: @@ -1508,7 +1530,6 @@ class WebsiteManager: 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) @@ -1536,7 +1557,7 @@ class WebsiteManager: path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + Webobj = Websites.objects.get(pk=wpsite.owner_id) Vhuser = Webobj.externalApp PHPVersion = Webobj.phpSelection @@ -1554,10 +1575,8 @@ class WebsiteManager: 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) @@ -1574,7 +1593,6 @@ class WebsiteManager: currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) - WPManagerID = data['WPid'] Theme = data['Theme'] Themearray = data['Themearray'] @@ -1587,15 +1605,13 @@ class WebsiteManager: path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + 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 @@ -1609,7 +1625,6 @@ class WebsiteManager: time.sleep(2) - data_ret = {'status': 1, 'error_message': 'None'} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -1638,7 +1653,7 @@ class WebsiteManager: path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + Webobj = Websites.objects.get(pk=wpsite.owner_id) Vhuser = Webobj.externalApp PHPVersion = Webobj.phpSelection @@ -1656,7 +1671,6 @@ class WebsiteManager: background = ApplicationInstaller('DeletePlugins', extraArgs) background.start() - time.sleep(2) data_ret = {'status': 1, 'error_message': 'None'} @@ -1681,7 +1695,7 @@ class WebsiteManager: wpsite = WPSites.objects.get(pk=WPManagerID) path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + Webobj = Websites.objects.get(pk=wpsite.owner_id) if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1: pass @@ -1693,8 +1707,6 @@ class WebsiteManager: php = ACLManager.getPHPString(PHPVersion) FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php) - - extraArgs = {} extraArgs['adminID'] = admin.pk extraArgs['Theme'] = Theme @@ -1703,12 +1715,9 @@ class WebsiteManager: 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) @@ -1736,30 +1745,30 @@ class WebsiteManager: path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + 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) + 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) + 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) + 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) @@ -1787,15 +1796,13 @@ class WebsiteManager: path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + 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 @@ -1803,14 +1810,9 @@ class WebsiteManager: 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) @@ -1840,6 +1842,11 @@ class WebsiteManager: else: return ACLManager.loadError() + + + + + background = ApplicationInstaller('CreateStagingNow', extraArgs) background.start() @@ -1880,47 +1887,50 @@ class WebsiteManager: path = wpsite.path - Webobj= Websites.objects.get(pk=wpsite.owner_id) + 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) - - if setting == 'lscache': if settingValue: - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin install litespeed-cache --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin install litespeed-cache --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) - - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin activate litespeed-cache --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin activate litespeed-cache --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) else: - command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin deactivate litespeed-cache --path=%s --skip-plugins --skip-themes' % (Vhuser, FinalPHPPath, path) + command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin deactivate litespeed-cache --path=%s --skip-plugins --skip-themes' % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) elif setting == 'debugging': - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp litespeed-purge all --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp litespeed-purge all --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) if settingValue: - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp config set WP_DEBUG true --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp config set WP_DEBUG true --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) logging.CyberCPLogFileWriter.writeToFile("Debugging mk true 1 output:" + str(stdoutput)) command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config list --skip-plugins --skip-themes --path=%s' % ( - Vhuser, FinalPHPPath, path) + Vhuser, FinalPHPPath, path) stdout = ProcessUtilities.outputExecutioner(command) logging.CyberCPLogFileWriter.writeToFile("Debugging output:" + str(stdout)) else: - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp config set WP_DEBUG false --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp config set WP_DEBUG false --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) logging.CyberCPLogFileWriter.writeToFile("Debugging mk false 0 output:" + str(stdoutput)) @@ -1930,30 +1940,36 @@ class WebsiteManager: logging.CyberCPLogFileWriter.writeToFile("Debugging output:" + str(stdout)) elif setting == 'searchIndex': - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp litespeed-purge all --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp litespeed-purge all --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) if settingValue: - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp option update blog_public 1 --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp option update blog_public 1 --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) else: - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp option update blog_public 0 --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp option update blog_public 0 --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) elif setting == 'maintenanceMode': - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp litespeed-purge all --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp litespeed-purge all --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) if settingValue: - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp maintenance-mode activate --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp maintenance-mode activate --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) else: - command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp maintenance-mode deactivate --path=%s --skip-plugins --skip-themes" % (Vhuser, FinalPHPPath, path) + command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp maintenance-mode deactivate --path=%s --skip-plugins --skip-themes" % ( + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) elif setting == 'PasswordProtection': execPath = f"/usr/local/CyberCP/bin/python {virtualHostUtilities.cyberPanel}/plogical/virtualHostUtilities.py" @@ -1964,14 +1980,14 @@ class WebsiteManager: elif setting == 'Wpcron': command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp litespeed-purge all --path=%s --skip-plugins --skip-themes" % ( - Vhuser, FinalPHPPath, path) + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) if settingValue: command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp config set DISABLE_WP_CRON true --path=%s --skip-plugins --skip-themes" % ( - Vhuser, FinalPHPPath, path) + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) @@ -1990,7 +2006,7 @@ class WebsiteManager: else: command = "sudo -u %s %s -d error_reporting=0 /usr/bin/wp config set DISABLE_WP_CRON false --path=%s --skip-plugins --skip-themes" % ( - Vhuser, FinalPHPPath, path) + Vhuser, FinalPHPPath, path) stdoutput = ProcessUtilities.outputExecutioner(command) @@ -2004,7 +2020,6 @@ class WebsiteManager: logging.CyberCPLogFileWriter.writeToFile("Debugging output:" + str(stdout)) - data_ret = {'status': 1, 'error_message': 'None'} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -2021,6 +2036,7 @@ class WebsiteManager: admin = Administrator.objects.get(pk=userID) + extraArgs = {} extraArgs['currentACL'] = currentACL extraArgs['adminID'] = admin.pk @@ -2075,6 +2091,24 @@ class WebsiteManager: packageName = data['package'] websiteOwner = data['websiteOwner'].lower() + if data['domainName'].find("cyberpanel.website") > -1: + url = "https://platform.cyberpersons.com/CyberpanelAdOns/CreateDomain" + + domain_data = { + "name": "test-domain", + "IP": ACLManager.GetServerIP(), + "domain": data['domainName'] + } + + import requests + response = requests.post(url, data=json.dumps(domain_data)) + domain_status = response.json()['status'] + + if domain_status == 0: + data_ret = {'status': 0, 'installStatus': 0, 'error_message': response.json()['error_message']} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + loggedUser = Administrator.objects.get(pk=userID) newOwner = Administrator.objects.get(userName=websiteOwner) @@ -2094,7 +2128,6 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - if not validators.email(adminEmail) or adminEmail.find('--') > -1: data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid email."} json_data = json.dumps(data_ret) @@ -2171,6 +2204,24 @@ class WebsiteManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) + if data['domainName'].find("cyberpanel.website") > -1: + url = "https://platform.cyberpersons.com/CyberpanelAdOns/CreateDomain" + + domain_data = { + "name": "test-domain", + "IP": ACLManager.GetServerIP(), + "domain": data['domainName'] + } + + import requests + response = requests.post(url, data=json.dumps(domain_data)) + domain_status = response.json()['status'] + + if domain_status == 0: + data_ret = {'status': 0, 'installStatus': 0, 'error_message': response.json()['error_message']} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + if ACLManager.checkOwnership(masterDomain, admin, currentACL) == 1: pass else: @@ -2433,6 +2484,17 @@ class WebsiteManager: def submitWebsiteDeletion(self, userID=None, data=None): try: + if data['websiteName'].find("cyberpanel.website") > -1: + url = "https://platform.cyberpersons.com/CyberpanelAdOns/DeleteDomain" + + domain_data = { + "name": "test-domain", + "IP": ACLManager.GetServerIP(), + "domain": data['websiteName'] + } + + import requests + response = requests.post(url, data=json.dumps(domain_data)) currentACL = ACLManager.loadedACL(userID) if ACLManager.currentContextPermission(currentACL, 'deleteWebsite') == 0: @@ -2464,6 +2526,18 @@ class WebsiteManager: def submitDomainDeletion(self, userID=None, data=None): try: + if data['websiteName'].find("cyberpanel.website") > -1: + url = "https://platform.cyberpersons.com/CyberpanelAdOns/DeleteDomain" + + domain_data = { + "name": "test-domain", + "IP": ACLManager.GetServerIP(), + "domain": data['websiteName'] + } + + import requests + response = requests.post(url, data=json.dumps(domain_data)) + currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) websiteName = data['websiteName'] @@ -4770,7 +4844,6 @@ StrictHostKeyChecking no website = Websites.objects.get(domain=self.domain) folders = ['/home/%s/public_html' % (self.domain)] - databases = website.databases_set.all() # for database in databases: @@ -5135,7 +5208,7 @@ StrictHostKeyChecking no ### set default ssh key command = 'git -C %s config --local core.sshCommand "ssh -i /home/%s/.ssh/%s -o "StrictHostKeyChecking=no""' % ( - self.folder, self.masterDomain, self.externalAppLocal) + self.folder, self.masterDomain, self.externalAppLocal) ProcessUtilities.executioner(command, self.externalAppLocal) ## Check if remote exists @@ -5147,10 +5220,10 @@ StrictHostKeyChecking no if remoteResult.find('origin') == -1: command = 'git -C %s remote add origin git@%s:%s/%s.git' % ( - self.folder, self.gitHost, self.gitUsername, self.gitReponame) + self.folder, self.gitHost, self.gitUsername, self.gitReponame) else: command = 'git -C %s remote set-url origin git@%s:%s/%s.git' % ( - self.folder, self.gitHost, self.gitUsername, self.gitReponame) + self.folder, self.gitHost, self.gitUsername, self.gitReponame) possibleError = ProcessUtilities.outputExecutioner(command, self.externalAppLocal) @@ -5559,7 +5632,7 @@ StrictHostKeyChecking no ## Set defauly key command = 'git config --global core.sshCommand "ssh -i /home/%s/.ssh/%s -o "StrictHostKeyChecking=no""' % ( - self.masterDomain, self.externalAppLocal) + self.masterDomain, self.externalAppLocal) ProcessUtilities.executioner(command, self.externalApp) ## @@ -5870,7 +5943,7 @@ StrictHostKeyChecking no self.externalApp = ACLManager.FetchExternalApp(self.domain) command = 'git -C %s show %s -- %s/%s' % ( - self.folder, self.commit, self.folder, self.file.strip('\n').strip(' ')) + self.folder, self.commit, self.folder, self.file.strip('\n').strip(' ')) fileChangedContent = ProcessUtilities.outputExecutioner(command, self.externalApp).split('\n') initialNumber = 0 @@ -5890,13 +5963,13 @@ StrictHostKeyChecking no fileLen = len(fileChangedContent) finalConent = '%s

%s

' % ( - '#', fileChangedContent[initialNumber]) + '#', fileChangedContent[initialNumber]) for i in range(initialNumber + 1, fileLen - 1): if fileChangedContent[i][0] == '@': lineNumber = int(fileChangedContent[i].split('+')[1].split(',')[0]) finalConent = finalConent + '%s

%s

' % ( - '#', fileChangedContent[i]) + '#', fileChangedContent[i]) continue else: @@ -5904,18 +5977,18 @@ StrictHostKeyChecking no content = '

%s

' % ( fileChangedContent[i].replace('<', "<").replace('>', ">")) finalConent = finalConent + '%s%s' % ( - str(lineNumber), content) + str(lineNumber), content) lineNumber = lineNumber + 1 elif fileChangedContent[i][0] == '-': content = '

%s

' % ( fileChangedContent[i].replace('<', "<").replace('>', ">")) finalConent = finalConent + '%s%s' % ( - str(lineNumber), content) + str(lineNumber), content) lineNumber = lineNumber + 1 else: content = '

%s

' % (fileChangedContent[i].replace('<', "<").replace('>', ">")) finalConent = finalConent + '%s%s' % ( - str(lineNumber), content) + str(lineNumber), content) lineNumber = lineNumber + 1 data_ret = {'status': 1, 'fileChangedContent': finalConent}