diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index 2476a370b..970f8dcd0 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -2455,6 +2455,7 @@ app.controller('createWebsite', function ($scope, $http, $timeout, $window) { mailDomain = 0 } + url = "/websites/submitWebsiteCreation"; var package = $scope.packageForWebsite; @@ -2634,16 +2635,14 @@ $("#listFail").hide(); app.controller('listWebsites', function ($scope, $http, $window) { - console.log('Initializing listWebsites controller'); $scope.web = {}; $scope.WebSitesList = []; - + $scope.currentPage = 1; $scope.recordsToShow = 10; // Initial fetch of websites $scope.getFurtherWebsitesFromDB = function () { - console.log('Fetching websites from DB'); var config = { headers: { 'X-CSRFToken': getCookie('csrftoken') @@ -2656,5581 +2655,17 @@ app.controller('listWebsites', function ($scope, $http, $window) { }; var dataurl = "/websites/fetchWebsitesList"; - console.log('Making request to:', dataurl); $http.post(dataurl, data, config).then(function(response) { - console.log('Received response:', response); if (response.data.listWebSiteStatus === 1) { - try { - $scope.WebSitesList = JSON.parse(response.data.data); - console.log('Parsed WebSitesList:', $scope.WebSitesList); - $scope.pagination = response.data.pagination; - $("#listFail").hide(); - } catch (e) { - console.error('Error parsing response data:', e); - $("#listFail").fadeIn(); - $scope.errorMessage = 'Error parsing server response'; - } - } else { - $("#listFail").fadeIn(); - $scope.errorMessage = response.data.error_message; - } - }).catch(function(error) { - console.error('Error fetching websites:', error); - $("#listFail").fadeIn(); - $scope.errorMessage = error.message || 'An error occurred while fetching websites'; - }); - }; - - // Call it immediately - $scope.getFurtherWebsitesFromDB(); - - $scope.showWPSites = function(index) { - console.log('showWPSites called with index:', index); - console.log('Current WebSitesList:', $scope.WebSitesList); - - $scope.selectedWebsite = $scope.WebSitesList[index]; - console.log('Selected website:', $scope.selectedWebsite); - - // Call the new GetWPSitesByDomain endpoint - var url = '/websites/GetWPSitesByDomain'; - var data = { - domain: $scope.selectedWebsite.domain - }; - - $http({ - method: 'POST', - url: url, - data: JSON.stringify(data), - headers: { - 'Content-Type': 'application/json', - 'X-CSRFToken': getCookie('csrftoken') - } - }).then(function(response) { - console.log('WP Sites Response:', response); - - if (response.data && response.data.status === 1) { - try { - // Display the data in an alert - var wpSites = response.data.data; - var alertMessage = 'WordPress Sites for ' + $scope.selectedWebsite.domain + ':\n\n'; - - wpSites.forEach(function(site, index) { - alertMessage += 'Site ' + (index + 1) + ':\n'; - alertMessage += 'Title: ' + site.title + '\n'; - alertMessage += 'URL: ' + site.url + '\n'; - alertMessage += 'Version: ' + site.version + '\n'; - alertMessage += 'PHP Version: ' + site.phpVersion + '\n'; - alertMessage += 'Active Plugins: ' + site.activePlugins + '\n'; - alertMessage += 'Theme: ' + site.theme + '\n'; - alertMessage += 'Debugging: ' + (site.debugging ? 'Enabled' : 'Disabled') + '\n'; - alertMessage += 'Search Index: ' + (site.searchIndex ? 'Enabled' : 'Disabled') + '\n'; - alertMessage += 'Maintenance Mode: ' + (site.maintenanceMode ? 'Enabled' : 'Disabled') + '\n'; - alertMessage += 'Password Protection: ' + (site.passwordProtection ? 'Enabled' : 'Disabled') + '\n\n'; - }); - - alert(alertMessage); - - // Update the UI with the data - $scope.selectedWebsite.wp_sites = wpSites; - $scope.selectedWebsite.showWPSites = true; - } catch (e) { - console.error('Error processing WordPress data:', e); - alert('Error processing WordPress data: ' + e.message); - $scope.selectedWebsite.showWPSites = false; - $scope.selectedWebsite.wp_sites = []; - } - } else { - console.error('Error fetching WordPress sites:', response.data.error_message); - alert('Error fetching WordPress sites: ' + response.data.error_message); - $scope.selectedWebsite.showWPSites = false; - $scope.selectedWebsite.wp_sites = []; - } - }, function(error) { - console.error('Error fetching WordPress sites:', error); - alert('Error fetching WordPress sites: ' + error.message); - $scope.selectedWebsite.showWPSites = false; - $scope.selectedWebsite.wp_sites = []; - }); - }; - - $scope.visitSite = function(url) { - window.open(url, '_blank'); - }; - - $scope.wpLogin = function(wpId) { - window.open('/websites/wpLogin?wpID=' + wpId, '_blank'); - }; - - $scope.manageWP = function(wpId) { - window.location.href = '/websites/listWPsites?wpID=' + wpId; - }; - - $scope.updateSetting = function(wp, setting) { - var settingMap = { - 'search-indexing': 'searchIndex', - 'debugging': 'debugging', - 'password-protection': 'passwordProtection', - 'maintenance-mode': 'maintenanceMode' - }; - - var data = { - wpID: wp.id, - setting: setting, - value: wp[settingMap[setting]] ? 'enable' : 'disable' - }; - - $http({ - method: 'POST', - url: '/websites/UpdateWPSettings', - data: data, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - 'X-CSRFToken': getCookie('csrftoken') - }, - transformRequest: function(obj) { - var str = []; - for(var p in obj) - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); - return str.join("&"); - } - }).then(function(response) { - if (response.data.status === 1) { - new PNotify({ - title: 'Success', - text: 'Setting updated successfully.', - type: 'success' - }); - } else { - wp[settingMap[setting]] = !wp[settingMap[setting]]; // Revert the change - new PNotify({ - title: 'Error', - text: 'Failed to update setting.', - type: 'error' - }); - } - }).catch(function(error) { - wp[settingMap[setting]] = !wp[settingMap[setting]]; // Revert the change - new PNotify({ - title: 'Error', - text: 'Connection failed while updating setting.', - type: 'error' - }); - }); - }; - - $scope.cyberPanelLoading = true; - - $scope.issueSSL = function (virtualHost) { - $scope.cyberPanelLoading = false; - - var url = "/manageSSL/issueSSL"; - - - var data = { - virtualHost: virtualHost - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - if (response.data.SSL === 1) { - new PNotify({ - title: 'Success!', - text: 'SSL successfully issued.', - type: 'success' - }); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - } - - } - - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type: 'error' - }); - } - - - }; - - $scope.cyberPanelLoading = true; - - $scope.searchWebsites = function () { - - $scope.cyberPanelLoading = false; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - var data = { - patternAdded: $scope.patternAdded - }; - - dataurl = "/websites/searchWebsites"; - - $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); - - - function ListInitialData(response) { - $scope.cyberPanelLoading = true; - if (response.data.listWebSiteStatus === 1) { - - var finalData = JSON.parse(response.data.data); - $scope.WebSitesList = finalData; - $("#listFail").hide(); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - } - - function cantLoadInitialData(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Connect disrupted, refresh the page.', - type: 'error' - }); - } - - - }; - - $scope.ScanWordpressSite = function () { - - $('#cyberPanelLoading').show(); - - - var url = "/websites/ScanWordpressSite"; - - var data = {} - - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - $('#cyberPanelLoading').hide(); - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Successfully Saved!.', - type: 'success' - }); - location.reload(); - - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#cyberPanelLoading').hide(); - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - - } - - - }; - -}); - -app.controller('listChildDomainsMain', function ($scope, $http, $timeout) { - - $scope.currentPage = 1; - $scope.recordsToShow = 10; - - $scope.getFurtherWebsitesFromDB = function () { - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - var data = { - page: $scope.currentPage, - recordsToShow: $scope.recordsToShow - }; - - - dataurl = "/websites/fetchChildDomainsMain"; - - $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); - - - function ListInitialData(response) { - if (response.data.listWebSiteStatus === 1) { - $scope.WebSitesList = JSON.parse(response.data.data); $scope.pagination = response.data.pagination; - $scope.clients = JSON.parse(response.data.data); $("#listFail").hide(); } else { $("#listFail").fadeIn(); $scope.errorMessage = response.data.error_message; - - } - } - - function cantLoadInitialData(response) { - } - - - }; - $scope.getFurtherWebsitesFromDB(); - - $scope.cyberPanelLoading = true; - - $scope.issueSSL = function (virtualHost) { - $scope.cyberPanelLoading = false; - - var url = "/manageSSL/issueSSL"; - - - var data = { - virtualHost: virtualHost - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - if (response.data.SSL === 1) { - new PNotify({ - title: 'Success!', - text: 'SSL successfully issued.', - type: 'success' - }); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - } - - } - - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type: 'error' - }); - } - - - }; - - $scope.cyberPanelLoading = true; - - $scope.searchWebsites = function () { - - $scope.cyberPanelLoading = false; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - var data = { - patternAdded: $scope.patternAdded - }; - - dataurl = "/websites/searchChilds"; - - $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); - - - function ListInitialData(response) { - $scope.cyberPanelLoading = true; - if (response.data.listWebSiteStatus === 1) { - - var finalData = JSON.parse(response.data.data); - $scope.WebSitesList = finalData; - $("#listFail").hide(); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - } - - function cantLoadInitialData(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Connect disrupted, refresh the page.', - type: 'error' - }); - } - - - }; - - $scope.initConvert = function (virtualHost) { - $scope.domainName = virtualHost; - }; - - var statusFile; - - $scope.installationProgress = true; - - $scope.convert = function () { - - $scope.cyberPanelLoading = false; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.goBackDisable = true; - - $scope.currentStatus = "Starting creation.."; - - var ssl, dkimCheck, openBasedir; - - if ($scope.sslCheck === true) { - ssl = 1; - } else { - ssl = 0 - } - - if ($scope.dkimCheck === true) { - dkimCheck = 1; - } else { - dkimCheck = 0 - } - - if ($scope.openBasedir === true) { - openBasedir = 1; - } else { - openBasedir = 0 - } - - url = "/websites/convertDomainToSite"; - - - var data = { - package: $scope.packageForWebsite, - domainName: $scope.domainName, - adminEmail: $scope.adminEmail, - phpSelection: $scope.phpSelection, - websiteOwner: $scope.websiteOwner, - ssl: ssl, - dkimCheck: dkimCheck, - openBasedir: openBasedir - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.createWebSiteStatus === 1) { - statusFile = response.data.tempStatusPath; - getCreationStatus(); - } else { - - $scope.cyberPanelLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.goBackDisable = false; - - $scope.currentStatus = response.data.error_message; - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.cyberPanelLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.goBackDisable = false; - - } - - - }; - $scope.goBack = function () { - $scope.cyberPanelLoading = true; - $scope.installationDetailsForm = false; - $scope.installationProgress = true; - $scope.goBackDisable = true; - $("#installProgress").css("width", "0%"); - }; - - function getCreationStatus() { - - url = "/websites/installWordpressStatus"; - - var data = { - statusFile: statusFile - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.abort === 1) { - - if (response.data.installStatus === 1) { - - $scope.cyberPanelLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.goBackDisable = false; - - $("#installProgress").css("width", "100%"); - $scope.installPercentage = "100"; - $scope.currentStatus = response.data.currentStatus; - $timeout.cancel(); - - } else { - - $scope.cyberPanelLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.goBackDisable = false; - - $scope.currentStatus = response.data.error_message; - - $("#installProgress").css("width", "0%"); - $scope.installPercentage = "0"; - $scope.goBackDisable = false; - - } - - } else { - $("#installProgress").css("width", response.data.installationProgress + "%"); - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - $timeout(getCreationStatus, 1000); - } - - } - - function cantLoadInitialDatas(response) { - - $scope.cyberPanelLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.goBackDisable = false; - - } - - - } - - var DeleteDomain; - $scope.deleteDomainInit = function (childDomainForDeletion) { - DeleteDomain = childDomainForDeletion; - }; - - $scope.deleteChildDomain = function () { - $scope.cyberPanelLoading = false; - url = "/websites/submitDomainDeletion"; - - var data = { - websiteName: DeleteDomain, - DeleteDocRoot: $scope.DeleteDocRoot - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - if (response.data.websiteDeleteStatus === 1) { - new PNotify({ - title: 'Success!', - text: 'Child Domain successfully deleted.', - type: 'success' - }); - $scope.getFurtherWebsitesFromDB(); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - } - } - - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type: 'error' - }); - - } - - }; - -}); - -/* Java script code to list accounts ends here */ - - -/* Java script code to delete Website */ - - -$("#websiteDeleteFailure").hide(); -$("#websiteDeleteSuccess").hide(); - -$("#deleteWebsiteButton").hide(); -$("#deleteLoading").hide(); - -app.controller('deleteWebsiteControl', function ($scope, $http) { - - - $scope.deleteWebsite = function () { - - $("#deleteWebsiteButton").fadeIn(); - - - }; - - $scope.deleteWebsiteFinal = function () { - - $("#deleteLoading").show(); - - var websiteName = $scope.websiteToBeDeleted; - - - url = "/websites/submitWebsiteDeletion"; - - var data = { - websiteName: websiteName - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.websiteDeleteStatus === 0) { - $scope.errorMessage = response.data.error_message; - $("#websiteDeleteFailure").fadeIn(); - $("#websiteDeleteSuccess").hide(); - $("#deleteWebsiteButton").hide(); - - - $("#deleteLoading").hide(); - - } else { - $("#websiteDeleteFailure").hide(); - $("#websiteDeleteSuccess").fadeIn(); - $("#deleteWebsiteButton").hide(); - $scope.deletedWebsite = websiteName; - $("#deleteLoading").hide(); - - } - - - } - - function cantLoadInitialDatas(response) { - } - - - }; - -}); - - -/* Java script code to delete website ends here */ - - -/* Java script code to modify package ends here */ - -$("#canNotModify").hide(); -$("#webSiteDetailsToBeModified").hide(); -$("#websiteModifyFailure").hide(); -$("#websiteModifySuccess").hide(); -$("#websiteSuccessfullyModified").hide(); -$("#modifyWebsiteLoading").hide(); -$("#modifyWebsiteButton").hide(); - -app.controller('modifyWebsitesController', function ($scope, $http) { - - $scope.fetchWebsites = function () { - - $("#modifyWebsiteLoading").show(); - - - var websiteToBeModified = $scope.websiteToBeModified; - - url = "/websites/getWebsiteDetails"; - - var data = { - websiteToBeModified: websiteToBeModified, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.modifyStatus === 0) { - console.log(response.data); - $scope.errorMessage = response.data.error_message; - $("#websiteModifyFailure").fadeIn(); - $("#websiteModifySuccess").hide(); - $("#modifyWebsiteButton").hide(); - $("#modifyWebsiteLoading").hide(); - $("#canNotModify").hide(); - - - } else { - console.log(response.data); - $("#modifyWebsiteButton").fadeIn(); - - $scope.adminEmail = response.data.adminEmail; - $scope.currentPack = response.data.current_pack; - $scope.webpacks = JSON.parse(response.data.packages); - $scope.adminNames = JSON.parse(response.data.adminNames); - $scope.currentAdmin = response.data.currentAdmin; - - $("#webSiteDetailsToBeModified").fadeIn(); - $("#websiteModifySuccess").fadeIn(); - $("#modifyWebsiteButton").fadeIn(); - $("#modifyWebsiteLoading").hide(); - $("#canNotModify").hide(); - - - } - - - } - - function cantLoadInitialDatas(response) { - $("#websiteModifyFailure").fadeIn(); - } - - }; - - - $scope.modifyWebsiteFunc = function () { - - var domain = $scope.websiteToBeModified; - var packForWeb = $scope.selectedPack; - var email = $scope.adminEmail; - var phpVersion = $scope.phpSelection; - var admin = $scope.selectedAdmin; - - - $("#websiteModifyFailure").hide(); - $("#websiteModifySuccess").hide(); - $("#websiteSuccessfullyModified").hide(); - $("#canNotModify").hide(); - $("#modifyWebsiteLoading").fadeIn(); - - - url = "/websites/saveWebsiteChanges"; - - var data = { - domain: domain, - packForWeb: packForWeb, - email: email, - phpVersion: phpVersion, - admin: admin - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.saveStatus === 0) { - $scope.errMessage = response.data.error_message; - - $("#canNotModify").fadeIn(); - $("#websiteModifyFailure").hide(); - $("#websiteModifySuccess").hide(); - $("#websiteSuccessfullyModified").hide(); - $("#modifyWebsiteLoading").hide(); - - - } else { - $("#modifyWebsiteButton").hide(); - $("#canNotModify").hide(); - $("#websiteModifyFailure").hide(); - $("#websiteModifySuccess").hide(); - - $("#websiteSuccessfullyModified").fadeIn(); - $("#modifyWebsiteLoading").hide(); - - $scope.websiteModified = domain; - - - } - - - } - - function cantLoadInitialDatas(response) { - $scope.errMessage = response.data.error_message; - $("#canNotModify").fadeIn(); - } - - - }; - -}); - -/* Java script code to Modify Pacakge ends here */ - - -/* 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) { - - $scope.logFileLoading = true; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = true; - $scope.couldNotConnect = true; - $scope.fetchedData = true; - $scope.hideLogs = true; - $scope.hideErrorLogs = true; - - $scope.hidelogsbtn = function () { - $scope.hideLogs = true; - }; - - $scope.hideErrorLogsbtn = function () { - $scope.hideLogs = true; - }; - - $scope.fileManagerURL = "/filemanager/" + $("#domainNamePage").text(); - $scope.wordPressInstallURL = $("#domainNamePage").text() + "/wordpressInstall"; - $scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall"; - $scope.setupGit = $("#domainNamePage").text() + "/setupGit"; - $scope.installPrestaURL = $("#domainNamePage").text() + "/installPrestaShop"; - $scope.installMagentoURL = $("#domainNamePage").text() + "/installMagento"; - $scope.installMauticURL = $("#domainNamePage").text() + "/installMautic"; - $scope.domainAliasURL = "/websites/" + $("#domainNamePage").text() + "/domainAlias"; - $scope.previewUrl = "/preview/" + $("#domainNamePage").text() + "/"; - - var logType = 0; - $scope.pageNumber = 1; - - $scope.fetchLogs = function (type) { - - var pageNumber = $scope.pageNumber; - - - if (type == 3) { - pageNumber = $scope.pageNumber + 1; - $scope.pageNumber = pageNumber; - } else if (type == 4) { - pageNumber = $scope.pageNumber - 1; - $scope.pageNumber = pageNumber; - } else { - logType = type; - } - - - $scope.logFileLoading = false; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = true; - $scope.couldNotConnect = true; - $scope.fetchedData = false; - $scope.hideErrorLogs = true; - - - url = "/websites/getDataFromLogFile"; - - var domainNamePage = $("#domainNamePage").text(); - - - var data = { - logType: logType, - virtualHost: domainNamePage, - page: pageNumber, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.logstatus == 1) { - - - $scope.logFileLoading = true; - $scope.logsFeteched = false; - $scope.couldNotFetchLogs = true; - $scope.couldNotConnect = true; - $scope.fetchedData = false; - $scope.hideLogs = false; - - - $scope.records = JSON.parse(response.data.data); - - } else { - - $scope.logFileLoading = true; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = false; - $scope.couldNotConnect = true; - $scope.fetchedData = true; - $scope.hideLogs = false; - - - $scope.errorMessage = response.data.error_message; - console.log(domainNamePage) - - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.logFileLoading = true; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = true; - $scope.couldNotConnect = false; - $scope.fetchedData = true; - $scope.hideLogs = false; - - } - - - }; - - $scope.errorPageNumber = 1; - - - $scope.fetchErrorLogs = function (type) { - - var errorPageNumber = $scope.errorPageNumber; - - - if (type == 3) { - errorPageNumber = $scope.errorPageNumber + 1; - $scope.errorPageNumber = errorPageNumber; - } else if (type == 4) { - errorPageNumber = $scope.errorPageNumber - 1; - $scope.errorPageNumber = errorPageNumber; - } else { - logType = type; - } - - // notifications - - $scope.logFileLoading = false; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = true; - $scope.couldNotConnect = true; - $scope.fetchedData = true; - $scope.hideErrorLogs = true; - $scope.hideLogs = false; - - - url = "/websites/fetchErrorLogs"; - - var domainNamePage = $("#domainNamePage").text(); - - - var data = { - virtualHost: domainNamePage, - page: errorPageNumber, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.logstatus === 1) { - - - // notifications - - $scope.logFileLoading = true; - $scope.logsFeteched = false; - $scope.couldNotFetchLogs = true; - $scope.couldNotConnect = true; - $scope.fetchedData = true; - $scope.hideLogs = false; - $scope.hideErrorLogs = false; - - - $scope.errorLogsData = response.data.data; - - } else { - - // notifications - - $scope.logFileLoading = true; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = false; - $scope.couldNotConnect = true; - $scope.fetchedData = true; - $scope.hideLogs = true; - $scope.hideErrorLogs = true; - - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - - // notifications - - $scope.logFileLoading = true; - $scope.logsFeteched = true; - $scope.couldNotFetchLogs = true; - $scope.couldNotConnect = false; - $scope.fetchedData = true; - $scope.hideLogs = true; - $scope.hideErrorLogs = true; - - } - - - }; - - ///////// Configurations Part - - $scope.configurationsBox = true; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = true; - $scope.couldNotConnect = true; - $scope.fetchedConfigsData = true; - $scope.configFileLoading = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = true; - - $scope.hideconfigbtn = function () { - - $scope.configurationsBox = true; - }; - - $scope.fetchConfigurations = function () { - - - $scope.hidsslconfigs = true; - $scope.configurationsBoxRewrite = true; - $scope.changePHPView = true; - - - //Rewrite rules - $scope.configurationsBoxRewrite = true; - $scope.rewriteRulesFetched = true; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = true; - - /// - - $scope.configFileLoading = false; - - - url = "/websites/getDataFromConfigFile"; - - var virtualHost = $("#domainNamePage").text(); - - - var data = { - virtualHost: virtualHost, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.configstatus === 1) { - - //Rewrite rules - - $scope.configurationsBoxRewrite = true; - $scope.rewriteRulesFetched = true; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = true; - - /// - - $scope.configurationsBox = false; - $scope.configsFetched = false; - $scope.couldNotFetchConfigs = true; - $scope.couldNotConnect = true; - $scope.fetchedConfigsData = false; - $scope.configFileLoading = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = true; - $scope.saveConfigBtn = false; - - - $scope.configData = response.data.configData; - - } else { - - //Rewrite rules - $scope.configurationsBoxRewrite = true; - $scope.rewriteRulesFetched = true; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = true; - - /// - $scope.configurationsBox = false; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = false; - $scope.couldNotConnect = true; - $scope.fetchedConfigsData = true; - $scope.configFileLoading = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = true; - - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - - //Rewrite rules - $scope.configurationsBoxRewrite = true; - $scope.rewriteRulesFetched = true; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = true; - /// - - $scope.configurationsBox = false; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = true; - $scope.couldNotConnect = false; - $scope.fetchedConfigsData = true; - $scope.configFileLoading = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = true; - - - } - - - }; - - $scope.saveCongiruations = function () { - - $scope.configFileLoading = false; - - - url = "/websites/saveConfigsToFile"; - - var virtualHost = $("#domainNamePage").text(); - var configData = $scope.configData; - - - var data = { - virtualHost: virtualHost, - configData: configData, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.configstatus === 1) { - - $scope.configurationsBox = false; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = true; - $scope.couldNotConnect = true; - $scope.fetchedConfigsData = true; - $scope.configFileLoading = true; - $scope.configSaved = false; - $scope.couldNotSaveConfigurations = true; - $scope.saveConfigBtn = true; - - - } else { - $scope.configurationsBox = false; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = true; - $scope.couldNotConnect = true; - $scope.fetchedConfigsData = false; - $scope.configFileLoading = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = false; - - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.configurationsBox = false; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = true; - $scope.couldNotConnect = false; - $scope.fetchedConfigsData = true; - $scope.configFileLoading = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = true; - - - } - - - }; - - - ///////// Rewrite Rules - - $scope.configurationsBoxRewrite = true; - $scope.rewriteRulesFetched = true; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = true; - - $scope.hideRewriteRulesbtn = function () { - $scope.configurationsBoxRewrite = true; - }; - - $scope.fetchRewriteFules = function () { - - $scope.hidsslconfigs = true; - $scope.configurationsBox = true; - $scope.changePHPView = true; - - - $scope.configurationsBox = true; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = true; - $scope.couldNotConnect = true; - $scope.fetchedConfigsData = true; - $scope.configFileLoading = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = true; - $scope.saveConfigBtn = true; - - $scope.configFileLoading = false; - - - url = "/websites/getRewriteRules"; - - var virtualHost = $("#domainNamePage").text(); - - - var data = { - virtualHost: virtualHost, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.rewriteStatus == 1) { - - - // from main - - $scope.configurationsBox = true; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = true; - $scope.fetchedConfigsData = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = true; - $scope.saveConfigBtn = true; - - // main ends - - $scope.configFileLoading = true; - - // - - - $scope.configurationsBoxRewrite = false; - $scope.rewriteRulesFetched = false; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = false; - $scope.saveRewriteRulesBTN = false; - $scope.couldNotConnect = true; - - - $scope.rewriteRules = response.data.rewriteRules; - - } else { - // from main - $scope.configurationsBox = true; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = true; - $scope.fetchedConfigsData = true; - $scope.configFileLoading = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = true; - $scope.saveConfigBtn = true; - // from main - - $scope.configFileLoading = true; - - /// - - $scope.configurationsBoxRewrite = true; - $scope.rewriteRulesFetched = true; - $scope.couldNotFetchRewriteRules = false; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = true; - $scope.couldNotConnect = true; - - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - // from main - - $scope.configurationsBox = true; - $scope.configsFetched = true; - $scope.couldNotFetchConfigs = true; - $scope.fetchedConfigsData = true; - $scope.configFileLoading = true; - $scope.configSaved = true; - $scope.couldNotSaveConfigurations = true; - $scope.saveConfigBtn = true; - - // from main - - $scope.configFileLoading = true; - - /// - - $scope.configurationsBoxRewrite = true; - $scope.rewriteRulesFetched = true; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = true; - - $scope.couldNotConnect = false; - - - } - - - }; - - $scope.saveRewriteRules = function () { - - $scope.configFileLoading = false; - - - url = "/websites/saveRewriteRules"; - - var virtualHost = $("#domainNamePage").text(); - var rewriteRules = $scope.rewriteRules; - - - var data = { - virtualHost: virtualHost, - rewriteRules: rewriteRules, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.rewriteStatus == 1) { - - $scope.configurationsBoxRewrite = false; - $scope.rewriteRulesFetched = true; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = false; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = true; - $scope.configFileLoading = true; - - - } else { - $scope.configurationsBoxRewrite = false; - $scope.rewriteRulesFetched = false; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = false; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = false; - - $scope.configFileLoading = true; - - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.configurationsBoxRewrite = false; - $scope.rewriteRulesFetched = false; - $scope.couldNotFetchRewriteRules = true; - $scope.rewriteRulesSaved = true; - $scope.couldNotSaveRewriteRules = true; - $scope.fetchedRewriteRules = true; - $scope.saveRewriteRulesBTN = false; - - $scope.configFileLoading = true; - - $scope.couldNotConnect = false; - - - } - - - }; - - //////// Application Installation part - - $scope.installationDetailsForm = true; - $scope.installationDetailsFormJoomla = true; - $scope.applicationInstallerLoading = true; - $scope.installationFailed = true; - $scope.installationSuccessfull = true; - $scope.couldNotConnect = true; - - - $scope.installationDetails = function () { - - $scope.installationDetailsForm = !$scope.installationDetailsForm; - $scope.installationDetailsFormJoomla = true; - - }; - - $scope.installationDetailsJoomla = function () { - - $scope.installationDetailsFormJoomla = !$scope.installationDetailsFormJoomla; - $scope.installationDetailsForm = true; - - }; - - $scope.installWordpress = function () { - - - $scope.installationDetailsForm = false; - $scope.applicationInstallerLoading = false; - $scope.installationFailed = true; - $scope.installationSuccessfull = true; - $scope.couldNotConnect = true; - - var domain = $("#domainNamePage").text(); - var path = $scope.installPath; - - url = "/websites/installWordpress"; - - var home = "1"; - - if (typeof path != 'undefined') { - home = "0"; - } - - - var data = { - domain: domain, - home: home, - path: path, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.installStatus === 1) { - if (typeof path != 'undefined') { - $scope.installationURL = "http://" + domain + "/" + path; - } else { - $scope.installationURL = domain; - } - - $scope.installationDetailsForm = false; - $scope.applicationInstallerLoading = true; - $scope.installationFailed = true; - $scope.installationSuccessfull = false; - $scope.couldNotConnect = true; - - } else { - - $scope.installationDetailsForm = false; - $scope.applicationInstallerLoading = true; - $scope.installationFailed = false; - $scope.installationSuccessfull = true; - $scope.couldNotConnect = true; - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.installationDetailsForm = false; - $scope.applicationInstallerLoading = true; - $scope.installationFailed = true; - $scope.installationSuccessfull = true; - $scope.couldNotConnect = false; - - } - - }; - - $scope.installJoomla = function () { - - - $scope.installationDetailsFormJoomla = false; - $scope.applicationInstallerLoading = false; - $scope.installationFailed = true; - $scope.installationSuccessfull = true; - $scope.couldNotConnect = true; - - var domain = $("#domainNamePage").text(); - var path = $scope.installPath; - var username = 'admin'; - var password = $scope.password; - var prefix = $scope.prefix; - - - url = "/websites/installJoomla"; - - var home = "1"; - - if (typeof path != 'undefined') { - home = "0"; - } - - - var data = { - domain: domain, - siteName: $scope.siteName, - home: home, - path: path, - password: password, - prefix: prefix, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.installStatus === 1) { - if (typeof path != 'undefined') { - $scope.installationURL = "http://" + domain + "/" + path; - } else { - $scope.installationURL = domain; - } - - $scope.installationDetailsFormJoomla = false; - $scope.applicationInstallerLoading = true; - $scope.installationFailed = true; - $scope.installationSuccessfull = false; - $scope.couldNotConnect = true; - - } else { - - $scope.installationDetailsFormJoomla = false; - $scope.applicationInstallerLoading = true; - $scope.installationFailed = false; - $scope.installationSuccessfull = true; - $scope.couldNotConnect = true; - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.installationDetailsFormJoomla = false; - $scope.applicationInstallerLoading = true; - $scope.installationFailed = true; - $scope.installationSuccessfull = true; - $scope.couldNotConnect = false; - - } - - }; - - - //////// SSL Part - - $scope.sslSaved = true; - $scope.couldNotSaveSSL = true; - $scope.hidsslconfigs = true; - $scope.couldNotConnect = true; - - - $scope.hidesslbtn = function () { - $scope.hidsslconfigs = true; - }; - - $scope.addSSL = function () { - $scope.hidsslconfigs = false; - $scope.configurationsBox = true; - $scope.configurationsBoxRewrite = true; - $scope.changePHPView = true; - }; - - $scope.saveSSL = function () { - - - $scope.configFileLoading = false; - - url = "/websites/saveSSL"; - - var virtualHost = $("#domainNamePage").text(); - var cert = $scope.cert; - var key = $scope.key; - - - var data = { - virtualHost: virtualHost, - cert: cert, - key: key - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.sslStatus === 1) { - - $scope.sslSaved = false; - $scope.couldNotSaveSSL = true; - $scope.couldNotConnect = true; - $scope.configFileLoading = true; - - - } else { - - $scope.sslSaved = true; - $scope.couldNotSaveSSL = false; - $scope.couldNotConnect = true; - $scope.configFileLoading = true; - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.sslSaved = true; - $scope.couldNotSaveSSL = true; - $scope.couldNotConnect = false; - $scope.configFileLoading = true; - - - } - - }; - - //// Change PHP Master - - $scope.failedToChangePHPMaster = true; - $scope.phpChangedMaster = true; - $scope.couldNotConnect = true; - - $scope.changePHPView = true; - - - $scope.hideChangePHPMaster = function () { - $scope.changePHPView = true; - }; - - $scope.changePHPMaster = function () { - $scope.hidsslconfigs = true; - $scope.configurationsBox = true; - $scope.configurationsBoxRewrite = true; - $scope.changePHPView = false; - }; - - $scope.changePHPVersionMaster = function (childDomain, phpSelection) { - - // notifcations - - $scope.configFileLoading = false; - - var url = "/websites/changePHP"; - - var data = { - childDomain: $("#domainNamePage").text(), - phpSelection: $scope.phpSelectionMaster, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.changePHP === 1) { - - $scope.configFileLoading = true; - $scope.websiteDomain = $("#domainNamePage").text(); - - - // notifcations - - $scope.failedToChangePHPMaster = true; - $scope.phpChangedMaster = false; - $scope.couldNotConnect = true; - - - } else { - - $scope.configFileLoading = true; - $scope.errorMessage = response.data.error_message; - - // notifcations - - $scope.failedToChangePHPMaster = false; - $scope.phpChangedMaster = true; - $scope.couldNotConnect = true; - - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.configFileLoading = true; - - // notifcations - - $scope.failedToChangePHPMaster = true; - $scope.phpChangedMaster = true; - $scope.couldNotConnect = false; - - } - - }; - - ////// create domain part - - $("#domainCreationForm").hide(); - - $scope.showCreateDomainForm = function () { - $("#domainCreationForm").fadeIn(); - }; - - $scope.hideDomainCreationForm = function () { - $("#domainCreationForm").fadeOut(); - }; - - $scope.masterDomain = $("#domainNamePage").text(); - - // notifcations settings - $scope.domainLoading = true; - $scope.installationDetailsForm = false; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $scope.DomainCreateForm = true; - - var statusFile; - - - $scope.webselection = true; - $scope.WebsiteType = function () { - var type = $scope.websitetype; - if (type == 'Sub Domain') { - $scope.webselection = false; - $scope.DomainCreateForm = true; - - } else if (type == 'Addon Domain') { - $scope.DomainCreateForm = false; - $scope.webselection = true; - $scope.masterDomain = $('#defaultSite').html() - } - }; - - $scope.WebsiteSelection = function () { - $scope.DomainCreateForm = false; - }; - - $scope.createDomain = function () { - - $scope.domainLoading = false; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $scope.currentStatus = "Starting creation.."; - $scope.DomainCreateForm = true; - - var ssl, dkimCheck, openBasedir, apacheBackend; - - if ($scope.sslCheck === true) { - ssl = 1; - } else { - ssl = 0 - } - - if ($scope.dkimCheck === true) { - dkimCheck = 1; - } else { - dkimCheck = 0 - } - - if ($scope.openBasedir === true) { - openBasedir = 1; - } else { - openBasedir = 0 - } - - - if ($scope.apacheBackend === true) { - apacheBackend = 1; - } else { - apacheBackend = 0 - } - - - url = "/websites/submitDomainCreation"; - var domainName = $scope.domainNameCreate; - var phpSelection = $scope.phpSelection; - - var path = $scope.docRootPath; - - 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 type = $scope.websitetype; - - var domainName = $scope.domainNameCreate; - - - var data = { - domainName: domainName, - phpSelection: phpSelection, - ssl: ssl, - path: path, - masterDomain: $scope.masterDomain, - dkimCheck: dkimCheck, - openBasedir: openBasedir, - apacheBackend: apacheBackend - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - // console.log(data) - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.createWebSiteStatus === 1) { - statusFile = response.data.tempStatusPath; - getCreationStatus(); - } else { - - $scope.domainLoading = true; - $scope.installationDetailsForm = true; - $scope.DomainCreateForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = false; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $scope.errorMessage = response.data.error_message; - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.domainLoading = true; - $scope.installationDetailsForm = true; - $scope.DomainCreateForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - }; - - $scope.goBack = function () { - $scope.domainLoading = true; - $scope.installationDetailsForm = false; - $scope.DomainCreateForm = true; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $scope.DomainCreateForm = true; - $("#installProgress").css("width", "0%"); - }; - - function getCreationStatus() { - - url = "/websites/installWordpressStatus"; - - var data = { - statusFile: statusFile - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.abort === 1) { - - if (response.data.installStatus === 1) { - - $scope.domainLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = false; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $("#installProgress").css("width", "100%"); - $scope.installPercentage = "100"; - $scope.currentStatus = response.data.currentStatus; - $timeout.cancel(); - - } else { - - $scope.domainLoading = true; - $scope.installationDetailsForm = true; - $scope.DomainCreateForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = false; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $scope.errorMessage = response.data.error_message; - - $("#installProgress").css("width", "0%"); - $scope.installPercentage = "0"; - $scope.goBackDisable = false; - - } - - } else { - $("#installProgress").css("width", response.data.installationProgress + "%"); - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - $timeout(getCreationStatus, 1000); - } - - } - - function cantLoadInitialDatas(response) { - - $scope.domainLoading = true; - $scope.installationDetailsForm = true; - $scope.DomainCreateForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - } - - - ////// List Domains Part - - //////////////////////// - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.childBaseDirChanged = true; - - $("#listDomains").hide(); - - - $scope.showListDomains = function () { - fetchDomains(); - $("#listDomains").fadeIn(); - }; - - $scope.hideListDomains = function () { - $("#listDomains").fadeOut(); - }; - - function fetchDomains() { - $scope.domainLoading = false; - - var url = "/websites/fetchDomains"; - - var data = { - masterDomain: $("#domainNamePage").text(), - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.fetchStatus === 1) { - - $scope.childDomains = JSON.parse(response.data.data); - $scope.domainLoading = true; - - - } else { - $scope.domainError = false; - $scope.errorMessage = response.data.error_message; - $scope.domainLoading = true; - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.couldNotConnect = false; - - } - - } - - $scope.changePHP = function (childDomain, phpSelection) { - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.domainLoading = false; - $scope.childBaseDirChanged = true; - - var url = "/websites/changePHP"; - - var data = { - childDomain: childDomain, - phpSelection: phpSelection, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.changePHP === 1) { - - $scope.domainLoading = true; - - $scope.changedPHPVersion = phpSelection; - - - // notifcations - - $scope.phpChanged = false; - $scope.domainError = true; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.childBaseDirChanged = true; - - - } else { - $scope.errorMessage = response.data.error_message; - $scope.domainLoading = true; - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = false; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.childBaseDirChanged = true; - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.domainLoading = true; - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = false; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.childBaseDirChanged = true; - - } - - }; - - $scope.changeChildBaseDir = function (childDomain, openBasedirValue) { - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.domainLoading = false; - $scope.childBaseDirChanged = true; - - - var url = "/websites/changeOpenBasedir"; - - var data = { - domainName: childDomain, - openBasedirValue: openBasedirValue - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.changeOpenBasedir === 1) { - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.domainLoading = true; - $scope.childBaseDirChanged = false; - - } else { - - $scope.phpChanged = true; - $scope.domainError = false; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.domainLoading = true; - $scope.childBaseDirChanged = true; - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = false; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.domainLoading = true; - $scope.childBaseDirChanged = true; - - - } - - } - - $scope.deleteChildDomain = function (childDomain) { - $scope.domainLoading = false; - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - - url = "/websites/submitDomainDeletion"; - - var data = { - websiteName: childDomain, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.websiteDeleteStatus === 1) { - - $scope.domainLoading = true; - $scope.deletedDomain = childDomain; - - fetchDomains(); - - - // notifications - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = true; - $scope.domainDeleted = false; - $scope.sslIssued = true; - - - } else { - $scope.errorMessage = response.data.error_message; - $scope.domainLoading = true; - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = false; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.domainLoading = true; - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = false; - $scope.domainDeleted = true; - $scope.sslIssued = true; - - } - - }; - - $scope.issueSSL = function (childDomain, path) { - $scope.domainLoading = false; - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.childBaseDirChanged = true; - - var url = "/manageSSL/issueSSL"; - - - var data = { - virtualHost: childDomain, - path: path, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.SSL === 1) { - - $scope.domainLoading = true; - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = false; - $scope.childBaseDirChanged = true; - - - $scope.sslDomainIssued = childDomain; - - - } else { - $scope.domainLoading = true; - - $scope.errorMessage = response.data.error_message; - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = false; - $scope.couldNotConnect = true; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.childBaseDirChanged = true; - - } - - - } - - function cantLoadInitialDatas(response) { - - // notifcations - - $scope.phpChanged = true; - $scope.domainError = true; - $scope.couldNotConnect = false; - $scope.domainDeleted = true; - $scope.sslIssued = true; - $scope.childBaseDirChanged = true; - - - } - - - }; - - - /// Open_basedir protection - - $scope.baseDirLoading = true; - $scope.operationFailed = true; - $scope.operationSuccessfull = true; - $scope.couldNotConnect = true; - $scope.openBaseDirBox = true; - - - $scope.openBaseDirView = function () { - $scope.openBaseDirBox = false; - }; - - $scope.hideOpenBasedir = function () { - $scope.openBaseDirBox = true; - }; - - $scope.applyOpenBasedirChanges = function (childDomain, phpSelection) { - - // notifcations - - $scope.baseDirLoading = false; - $scope.operationFailed = true; - $scope.operationSuccessfull = true; - $scope.couldNotConnect = true; - $scope.openBaseDirBox = false; - - - var url = "/websites/changeOpenBasedir"; - - var data = { - domainName: $("#domainNamePage").text(), - openBasedirValue: $scope.openBasedirValue - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.changeOpenBasedir === 1) { - - $scope.baseDirLoading = true; - $scope.operationFailed = true; - $scope.operationSuccessfull = false; - $scope.couldNotConnect = true; - $scope.openBaseDirBox = false; - - } else { - - $scope.baseDirLoading = true; - $scope.operationFailed = false; - $scope.operationSuccessfull = true; - $scope.couldNotConnect = true; - $scope.openBaseDirBox = false; - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.baseDirLoading = true; - $scope.operationFailed = true; - $scope.operationSuccessfull = true; - $scope.couldNotConnect = false; - $scope.openBaseDirBox = false; - - - } - - } - - - // REWRITE Template - - const httpToHTTPS = `### Rewrite Rules Added by CyberPanel Rewrite Rule Generator - -RewriteEngine On -RewriteCond %{HTTPS} !=on -RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] - -### End CyberPanel Generated Rules. - -`; - - const WWWToNonWWW = `### Rewrite Rules Added by CyberPanel Rewrite Rule Generator - -RewriteEngine On -RewriteCond %{HTTP_HOST} ^www\.(.*)$ -RewriteRule ^(.*)$ http://%1/$1 [L,R=301] - -### End CyberPanel Generated Rules. - -`; - - const nonWWWToWWW = `### Rewrite Rules Added by CyberPanel Rewrite Rule Generator - -RewriteEngine On -RewriteCond %{HTTP_HOST} !^www\. [NC] -RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] - -### End CyberPanel Generated Rules. - -`; - - const WordpressProtect = `### Rewrite Rules Added by CyberPanel Rewrite Rule Generator - -RewriteEngine On -RewriteRule ^/(xmlrpc|wp-trackback)\.php - [F,L,NC] - -### End CyberPanel Generated Rules. - -`; - - $scope.applyRewriteTemplate = function () { - - if ($scope.rewriteTemplate === "Force HTTP -> HTTPS") { - $scope.rewriteRules = httpToHTTPS + $scope.rewriteRules; - } else if ($scope.rewriteTemplate === "Force NON-WWW -> WWW") { - $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") { - $scope.rewriteRules = WordpressProtect + $scope.rewriteRules; - } - }; - - -}); - -/* Java script code to create account ends here */ - -/* Java script code to suspend/un-suspend Website */ - -app.controller('suspendWebsiteControl', function ($scope, $http) { - - $scope.suspendLoading = true; - $scope.stateView = true; - - $scope.websiteSuspendFailure = true; - $scope.websiteUnsuspendFailure = true; - $scope.websiteSuccess = true; - $scope.couldNotConnect = true; - - $scope.showSuspendUnsuspend = function () { - - $scope.stateView = false; - - - }; - - $scope.save = function () { - - $scope.suspendLoading = false; - - var websiteName = $scope.websiteToBeSuspended - var state = $scope.state; - - - url = "/websites/submitWebsiteStatus"; - - var data = { - websiteName: websiteName, - state: state, - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.websiteStatus === 1) { - if (state == "Suspend") { - - $scope.suspendLoading = true; - $scope.stateView = false; - - $scope.websiteSuspendFailure = true; - $scope.websiteUnsuspendFailure = true; - $scope.websiteSuccess = false; - $scope.couldNotConnect = true; - - $scope.websiteStatus = websiteName; - $scope.finalStatus = "Suspended"; - - } else { - $scope.suspendLoading = true; - $scope.stateView = false; - - $scope.websiteSuspendFailure = true; - $scope.websiteUnsuspendFailure = true; - $scope.websiteSuccess = false; - $scope.couldNotConnect = true; - - $scope.websiteStatus = websiteName; - $scope.finalStatus = "Un-suspended"; - - } - - } else { - - if (state == "Suspend") { - - $scope.suspendLoading = true; - $scope.stateView = false; - - $scope.websiteSuspendFailure = false; - $scope.websiteUnsuspendFailure = true; - $scope.websiteSuccess = true; - $scope.couldNotConnect = true; - - - } else { - $scope.suspendLoading = true; - $scope.stateView = false; - - $scope.websiteSuspendFailure = true; - $scope.websiteUnsuspendFailure = false; - $scope.websiteSuccess = true; - $scope.couldNotConnect = true; - - - } - - - $scope.errorMessage = response.data.error_message; - - } - - - } - - function cantLoadInitialDatas(response) { - $scope.couldNotConnect = false; - $scope.suspendLoading = true; - $scope.stateView = true; - - $scope.websiteSuspendFailure = true; - $scope.websiteUnsuspendFailure = true; - $scope.websiteSuccess = true; - - } - - - }; - -}); - -/** - * Created by usman on 7/26/17. - */ -function getCookie(name) { - var cookieValue = null; - var t = document.cookie; - if (document.cookie && document.cookie !== '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) === (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} - - -var arry = [] - -function selectpluginJs(val) { - $('#mysearch').hide() - arry.push(val) - - // console.log(arry) - document.getElementById('selJS').innerHTML = ""; - - for (var i = 0; i < arry.length; i++) { - $('#selJS').show() - var mlm = ' ' + arry[i] + '    ' - $('#selJS').append(mlm) - } - - -} - - -var DeletePluginURL; - -function DeletePluginBuucket(url) { - DeletePluginURL = url; -} - -function FinalDeletePluginBuucket() { - window.location.href = DeletePluginURL; -} - -var SPVal; - -app.controller('WPAddNewPlugin', function ($scope, $http, $timeout, $window, $compile) { - $scope.webSiteCreationLoading = true; - - $scope.SearchPluginName = function (val) { - $scope.webSiteCreationLoading = false; - SPVal = val; - url = "/websites/SearchOnkeyupPlugin"; - - var searchcontent = $scope.searchcontent; - - - var data = { - pluginname: searchcontent - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.webSiteCreationLoading = true; - - if (response.data.status === 1) { - if (SPVal == 'add') { - $('#mysearch').show() - document.getElementById('mysearch').innerHTML = ""; - var res = response.data.plugns.plugins - // console.log(res); - for (i = 0; i <= res.length; i++) { - // - var tml = '
'; - $('#mysearch').append(tml); - } - } else if (SPVal == 'eidt') { - $('#mysearch').show() - document.getElementById('mysearch').innerHTML = ""; - var res = response.data.plugns.plugins - // console.log(res); - for (i = 0; i <= res.length; i++) { - // - var tml = '
'; - var temp = $compile(tml)($scope) - angular.element(document.getElementById('mysearch')).append(temp); - } - - } - - - } else { - - // $scope.errorMessage = response.data.error_message; - alert("Status not = 1: Error..." + response.data.error_message) - } - - - } - - function cantLoadInitialDatas(response) { - - alert("Error..." + response) - - } - } - - $scope.AddNewplugin = function () { - - url = "/websites/AddNewpluginAjax"; - - var bucketname = $scope.PluginbucketName - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - var data = { - config: arry, - Name: bucketname - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - function ListInitialDatas(response) { - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Bucket created.', - type: 'success' - }); - location.reload(); - } else { - - new PNotify({ - title: 'Error!', - text: response.data.error_message, - type: 'error' - }); - } - - - } - - function cantLoadInitialDatas(response) { - - alert("Error..." + response) - - } - } - - $scope.deletesPlgin = function (val) { - - url = "/websites/deletesPlgin"; - - - var data = { - pluginname: val, - pluginbBucketID: $('#pluginbID').html() - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.status === 1) { - location.reload(); - - } else { - - // $scope.errorMessage = response.data.error_message; - alert("Status not = 1: Error..." + response.data.error_message) - } - - - } - - function cantLoadInitialDatas(response) { - - alert("Error..." + response) - - } - - } - - $scope.Addplugin = function (slug) { - $('#mysearch').hide() - - url = "/websites/Addplugineidt"; - - - var data = { - pluginname: slug, - pluginbBucketID: $('#pluginbID').html() - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.status === 1) { - location.reload(); - - } else { - - // $scope.errorMessage = response.data.error_message; - alert("Status not = 1: Error..." + response.data.error_message) - } - - - } - - function cantLoadInitialDatas(response) { - - alert("Error..." + response) - - } - - - } - -}); - -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; - $scope.installationDetailsForm = false; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - - - var statusFile; - - $scope.createWordPresssite = function () { - - $scope.webSiteCreationLoading = false; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - - - $scope.currentStatus = "Starting creation.."; - - var apacheBackend = 0; - - if ($scope.apacheBackend === true) { - apacheBackend = 1; - } else { - apacheBackend = 0 - } - - var package = $scope.packageForWebsite; - var websiteOwner = $scope.websiteOwner; - var WPtitle = $scope.WPtitle; - - // 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 domainNameCreate = $scope.domainNameCreate; - - - var WPUsername = $scope.WPUsername; - var adminEmail = $scope.adminEmail; - var WPPassword = $scope.WPPassword; - var WPVersions = $scope.WPVersions; - var pluginbucket = $scope.pluginbucket; - var autoupdates = $scope.autoupdates; - var pluginupdates = $scope.pluginupdates; - var themeupdates = $scope.themeupdates; - - if (domain_check == 0) { - - var path = ""; - - } - if (domain_check = 1) { - - var path = $scope.installPath; - - } - - - var home = "1"; - - if (typeof path != 'undefined') { - home = "0"; - } - - //alert(domainNameCreate); - var data = { - - title: WPtitle, - domain: domainNameCreate, - WPVersion: WPVersions, - pluginbucket: pluginbucket, - adminUser: WPUsername, - Email: adminEmail, - PasswordByPass: WPPassword, - AutomaticUpdates: autoupdates, - Plugins: pluginupdates, - Themes: themeupdates, - websiteOwner: websiteOwner, - package: package, - home: home, - path: path, - apacheBackend: apacheBackend - } - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - var url = "/websites/submitWorpressCreation"; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.webSiteCreationLoading = true; - if (response.data.status === 1) { - statusFile = response.data.tempStatusPath; - getCreationStatus(); - - } else { - $scope.goBackDisable = false; - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - } - - } - - function cantLoadInitialDatas(response) { - - alert("Error..." + response) - - } - - }; - $scope.goBack = function () { - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = false; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $("#installProgress").css("width", "0%"); - }; - - function getCreationStatus() { - - url = "/websites/installWordpressStatus"; - - var data = { - statusFile: statusFile - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.abort === 1) { - - if (response.data.installStatus === 1) { - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = false; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $("#installProgress").css("width", "100%"); - $scope.installPercentage = "100"; - $scope.currentStatus = response.data.currentStatus; - $timeout.cancel(); - - } else { - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = false; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $scope.errorMessage = response.data.error_message; - - $("#installProgress").css("width", "0%"); - $scope.installPercentage = "0"; - $scope.goBackDisable = false; - - } - - } else { - $scope.webSiteCreationLoading = false; - $("#installProgress").css("width", response.data.installationProgress + "%"); - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - $timeout(getCreationStatus, 1000); - } - - } - - function cantLoadInitialDatas(response) { - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - } - - -}); - - -//........... delete wp list -var FurlDeleteWP; - -function DeleteWPNow(url) { - FurlDeleteWP = url; -} - -function FinalDeleteWPNow() { - window.location.href = FurlDeleteWP; -} - -var DeploytoProductionID; - -function DeployToProductionInitial(vall) { - DeploytoProductionID = vall; -} - -var create_staging_domain_check = 0; - -function create_staging_checkbox_function() { - - try { - - 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; - } - } catch (e) { - - } - - // alert(domain_check); -} - -create_staging_checkbox_function(); - -app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $window) { - - var CheckBoxpasssword = 0; - - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = false; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $(document).ready(function () { - var checkstatus = document.getElementById("wordpresshome"); - if (checkstatus !== null) { - $scope.LoadWPdata(); - - } - }); - - - $scope.LoadWPdata = function () { - - $scope.wordpresshomeloading = false; - $('#wordpresshomeloading').show(); - - var url = "/websites/FetchWPdata"; - - var data = { - WPid: $('#WPid').html(), - } - - console.log(data); - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - wordpresshomeloading = true; - $('#wordpresshomeloading').hide(); - - if (response.data.status === 1) { - $('#WPVersion').text(response.data.ret_data.version); - if (response.data.ret_data.lscache === 1) { - $('#lscache').prop('checked', true); - } - if (response.data.ret_data.debugging === 1) { - $('#debugging').prop('checked', true); - } - if (response.data.ret_data.searchIndex === 1) { - $('#searchIndex').prop('checked', true); - } - if (response.data.ret_data.maintenanceMode === 1) { - $('#maintenanceMode').prop('checked', true); - } - if (response.data.ret_data.wpcron === 1) { - $('#wpcron').prop('checked', true); - } - if (response.data.ret_data.passwordprotection == 1) { - - var dc = '\n' + - ' ' - var mp = $compile(dc)($scope); - angular.element(document.getElementById('prsswdprodata')).append(mp); - CheckBoxpasssword = 1; - } else if (response.data.ret_data.passwordprotection == 0) { - var dc = '\n' + - ' ' - $('#prsswdprodata').append(dc); - CheckBoxpasssword = 0; - } - - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - }; - - $scope.UpdateWPSettings = function (setting) { - - $scope.wordpresshomeloading = false; - $('#wordpresshomeloading').show(); - - - var url = "/websites/UpdateWPSettings"; - - if (setting === "PasswordProtection") { - if (CheckBoxpasssword == 0) { - var data = { - WPid: $('#WPid').html(), - setting: setting, - PPUsername: $scope.PPUsername, - PPPassword: $scope.PPPassword, - } - - } else { - var data = { - WPid: $('#WPid').html(), - setting: setting, - PPUsername: '', - PPPassword: '', - } - - } - - } else { - var settingValue = 0; - if ($('#' + setting).is(":checked")) { - settingValue = 1; - } - var data = { - WPid: $('#WPid').html(), - setting: setting, - settingValue: settingValue - } - } - - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.wordpresshomeloading = true; - $('#wordpresshomeloading').hide(); - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Successfully Updated!.', - type: 'success' - }); - if (setting === "PasswordProtection") { - location.reload(); - } - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - if (setting === "PasswordProtection") { - location.reload(); - } - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - - - }; - - $scope.GetCurrentPlugins = function () { - $('#wordpresshomeloading').show(); - - $scope.wordpresshomeloading = false; - - var url = "/websites/GetCurrentPlugins"; - - var data = { - WPid: $('#WPid').html(), - } - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - wordpresshomeloading = true; - $('#wordpresshomeloading').hide(); - - if (response.data.status === 1) { - $('#PluginBody').html(''); - var plugins = JSON.parse(response.data.plugins); - plugins.forEach(AddPlugins); - - } else { - alert("Error:" + response.data.error_message) - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - }; - - $scope.GetCurrentThemes = function () { - $('#wordpresshomeloading').show(); - - $scope.wordpresshomeloading = false; - - var url = "/websites/GetCurrentThemes"; - - var data = { - WPid: $('#WPid').html(), - } - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - wordpresshomeloading = true; - $('#wordpresshomeloading').hide(); - - if (response.data.status === 1) { - - $('#ThemeBody').html(''); - var themes = JSON.parse(response.data.themes); - themes.forEach(AddThemes); - - } else { - alert("Error:" + response.data.error_message) - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - }; - - $scope.UpdatePlugins = function (plugin) { - $('#wordpresshomeloading').show(); - var data = { - plugin: plugin, - pluginarray: PluginsList, - WPid: $('#WPid').html(), - } - - $scope.wordpresshomeloading = false; - - var url = "/websites/UpdatePlugins"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Updating Plugins in Background!.', - type: 'success' - }); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - - - }; - - $scope.DeletePlugins = function (plugin) { - $('#wordpresshomeloading').show(); - var data = { - plugin: plugin, - pluginarray: PluginsList, - WPid: $('#WPid').html(), - } - - $scope.wordpresshomeloading = false; - - var url = "/websites/DeletePlugins"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Deleting Plugin in Background!', - type: 'success' - }); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - - } - - $scope.ChangeStatus = function (plugin) { - $('#wordpresshomeloading').show(); - var data = { - plugin: plugin, - WPid: $('#WPid').html(), - } - - $scope.wordpresshomeloading = false; - - var url = "/websites/ChangeStatus"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Changed Plugin state Successfully !.', - type: 'success' - }); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - - } - - function AddPlugins(value, index, array) { - var FinalMarkup = '' - FinalMarkup = FinalMarkup + ''; - for (let x in value) { - if (x === 'status') { - if (value[x] === 'inactive') { - FinalMarkup = FinalMarkup + '
'; - } else { - FinalMarkup = FinalMarkup + '
'; - } - } else if (x === 'update') { - if (value[x] === 'none') { - FinalMarkup = FinalMarkup + 'Upto Date'; - } else { - FinalMarkup = FinalMarkup + ''; - } - } else { - FinalMarkup = FinalMarkup + '' + value[x] + ""; - } - } - FinalMarkup = FinalMarkup + '' - FinalMarkup = FinalMarkup + '' - var temp = $compile(FinalMarkup)($scope) - AppendToTable('#PluginBody', temp) - } - - $scope.UpdateThemes = function (theme) { - $('#wordpresshomeloading').show(); - var data = { - Theme: theme, - Themearray: ThemesList, - WPid: $('#WPid').html(), - } - - $scope.wordpresshomeloading = false; - - var url = "/websites/UpdateThemes"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Updating Theme in background !.', - type: 'success' - }); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - - - }; - - $scope.DeleteThemes = function (theme) { - $('#wordpresshomeloading').show(); - var data = { - Theme: theme, - Themearray: ThemesList, - WPid: $('#WPid').html(), - } - - $scope.wordpresshomeloading = false; - - var url = "/websites/DeleteThemes"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Deleting Theme in Background!.', - type: 'success' - }); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - }; - - $scope.ChangeStatusThemes = function (theme) { - $('#wordpresshomeloading').show(); - var data = { - theme: theme, - WPid: $('#WPid').html(), - } - - $scope.wordpresshomeloading = false; - - var url = "/websites/StatusThemes"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Change Theme state in Bsckground!.', - type: 'success' - }); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - - }; - - function AddThemes(value, index, array) { - var FinalMarkup = '' - FinalMarkup = FinalMarkup + ''; - for (let x in value) { - if (x === 'status') { - if (value[x] === 'inactive') { - FinalMarkup = FinalMarkup + '
'; - } else { - FinalMarkup = FinalMarkup + '
'; - } - } else if (x === 'update') { - if (value[x] === 'none') { - FinalMarkup = FinalMarkup + 'Upto Date'; - } else { - FinalMarkup = FinalMarkup + ''; - } - } else { - FinalMarkup = FinalMarkup + '' + value[x] + ""; - } - } - FinalMarkup = FinalMarkup + '' - FinalMarkup = FinalMarkup + '' - var temp = $compile(FinalMarkup)($scope) - AppendToTable('#ThemeBody', temp) - } - - $scope.CreateStagingNow = function () { - $('#wordpresshomeloading').show(); - - $scope.wordpresshomeloading = false; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - - - $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: domainNameCreate, - WPid: $('#WPid').html(), - } - var url = "/websites/CreateStagingNow"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - if (response.data.status === 1) { - statusFile = response.data.tempStatusPath; - getCreationStatus(); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - }; - - function getCreationStatus() { - $('#wordpresshomeloading').show(); - - url = "/websites/installWordpressStatus"; - - var data = { - statusFile: statusFile - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - //$('#wordpresshomeloading').hide(); - - if (response.data.abort === 1) { - if (response.data.installStatus === 1) { - - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = false; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - - $("#installProgress").css("width", "100%"); - $("#installProgressbackup").css("width", "100%"); - $scope.installPercentage = "100"; - $scope.currentStatus = response.data.currentStatus; - $timeout.cancel(); - - - } else { - - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = false; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $scope.errorMessage = response.data.error_message; - - $("#installProgress").css("width", "0%"); - $("#installProgressbackup").css("width", "0%"); - $scope.installPercentage = "0"; - $scope.goBackDisable = false; - - - } - - } else { - - $("#installProgress").css("width", response.data.installationProgress + "%"); - $("#installProgressbackup").css("width", response.data.installationProgress + "%"); - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - $timeout(getCreationStatus, 1000); - - } - - } - - function cantLoadInitialDatas(response) { - //$('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - } - - $scope.goBack = function () { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = false; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $("#installProgress").css("width", "0%"); - }; - - $scope.fetchstaging = function () { - - $('#wordpresshomeloading').show(); - $scope.wordpresshomeloading = false; - - var url = "/websites/fetchstaging"; - - var data = { - WPid: $('#WPid').html(), - } - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - wordpresshomeloading = true; - $('#wordpresshomeloading').hide(); - - if (response.data.status === 1) { - - // $('#ThemeBody').html(''); - // var themes = JSON.parse(response.data.themes); - // themes.forEach(AddThemes); - - $('#StagingBody').html(''); - var staging = JSON.parse(response.data.wpsites); - staging.forEach(AddStagings); - - } else { - alert("Error data.error_message:" + response.data.error_message) - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - alert("Error" + response) - - } - - }; - - $scope.fetchDatabase = function () { - - $('#wordpresshomeloading').show(); - $scope.wordpresshomeloading = false; - - var url = "/websites/fetchDatabase"; - - var data = { - WPid: $('#WPid').html(), - } - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - wordpresshomeloading = true; - $('#wordpresshomeloading').hide(); - - if (response.data.status === 1) { - $('#DB_Name').html(response.data.DataBaseName); - $('#DB_User').html(response.data.DataBaseUser); - $('#tableprefix').html(response.data.tableprefix); - } else { - alert("Error data.error_message:" + response.data.error_message) - - } - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - alert("Error" + response) - - } - - }; - - $scope.SaveUpdateConfig = function () { - $('#wordpresshomeloading').show(); - var data = { - AutomaticUpdates: $('#AutomaticUpdates').find(":selected").text(), - Plugins: $('#Plugins').find(":selected").text(), - Themes: $('#Themes').find(":selected").text(), - WPid: $('#WPid').html(), - } - - $scope.wordpresshomeloading = false; - - var url = "/websites/SaveUpdateConfig"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Update Configurations Sucessfully!.', - type: 'success' - }); - $("#autoUpdateConfig").modal('hide'); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - new PNotify({ - title: 'Operation Failed!', - text: response, - type: 'error' - }); - - } - }; - - function AddStagings(value, index, array) { - var FinalMarkup = '' - for (let x in value) { - if (x === 'name') { - FinalMarkup = FinalMarkup + '' + value[x] + ''; - } else if (x !== 'url' && x !== 'deleteURL' && x !== 'id') { - FinalMarkup = FinalMarkup + '' + value[x] + ""; - } - } - FinalMarkup = FinalMarkup + '' + - ' ' - FinalMarkup = FinalMarkup + '' - AppendToTable('#StagingBody', FinalMarkup); - } - - $scope.FinalDeployToProduction = function () { - - $('#wordpresshomeloading').show(); - - $scope.wordpresshomeloading = false; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - - var data = { - WPid: $('#WPid').html(), - StagingID: DeploytoProductionID - } - - var url = "/websites/DeploytoProduction"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - function ListInitialDatas(response) { - - $('#wordpresshomeloading').hide(); - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Deploy To Production start!.', - type: 'success' - }); - statusFile = response.data.tempStatusPath; - getCreationStatus(); - - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - new PNotify({ - title: 'Operation Failed!', - text: response, - type: 'error' - }); - - } - - }; - - - $scope.CreateBackup = function () { - $('#wordpresshomeloading').show(); - - $scope.wordpresshomeloading = false; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $scope.currentStatus = "Starting creation Backups.."; - var data = { - WPid: $('#WPid').html(), - Backuptype: $('#backuptype').val() - } - var url = "/websites/WPCreateBackup"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $('createbackupbutton').hide(); - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Creating Backups!.', - type: 'success' - }); - statusFile = response.data.tempStatusPath; - getCreationStatus(); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - alert(response) - - } - - }; - - - $scope.installwpcore = function () { - - $('#wordpresshomeloading').show(); - $('#wordpresshomeloadingsec').show(); - var data = { - WPid: $('#WPid').html(), - } - - $scope.wordpresshomeloading = false; - - var url = "/websites/installwpcore"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $('#wordpresshomeloadingsec').hide(); - $scope.wordpresshomeloading = true; - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Results fetched..', - type: 'success' - }); - $('#SecurityResult').html(response.data.result); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $('#wordpresshomeloadingsec').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - - }; - - $scope.dataintegrity = function () { - - $('#wordpresshomeloading').show(); - $('#wordpresshomeloadingsec').show(); - var data = { - WPid: $('#WPid').html(), - } - - $scope.wordpresshomeloading = false; - - var url = "/websites/dataintegrity"; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $('#wordpresshomeloadingsec').hide(); - $scope.wordpresshomeloading = true; - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Results fetched', - type: 'success' - }); - $('#SecurityResult').html(response.data.result); - } else { - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - $('#wordpresshomeloadingsec').hide(); - $scope.wordpresshomeloading = true; - alert(response) - - } - }; - -}); - - -var PluginsList = []; - - -function AddPluginToArray(cBox, name) { - if (cBox.checked) { - PluginsList.push(name); - // alert(PluginsList); - } else { - const index = PluginsList.indexOf(name); - if (index > -1) { - PluginsList.splice(index, 1); - } - // alert(PluginsList); - } -} - -var ThemesList = []; - -function AddThemeToArray(cBox, name) { - if (cBox.checked) { - ThemesList.push(name); - // alert(ThemesList); - } else { - const index = ThemesList.indexOf(name); - if (index > -1) { - ThemesList.splice(index, 1); - } - // alert(ThemesList); - } -} - - -function AppendToTable(table, markup) { - $(table).append(markup); -} - - -//..................Restore Backup Home - - -app.controller('RestoreWPBackup', function ($scope, $http, $timeout, $window) { - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = false; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - - - $scope.checkmethode = function () { - var val = $('#RestoreMethode').children("option:selected").val(); - if (val == 1) { - $('#Newsitediv').show(); - $('#exinstingsitediv').hide(); - } else if (val == 0) { - $('#exinstingsitediv').show(); - $('#Newsitediv').hide(); - } else { - - } - }; - - - $scope.RestoreWPbackupNow = function () { - $('#wordpresshomeloading').show(); - $scope.wordpresshomeloading = false; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $scope.currentStatus = "Start Restoring WordPress.."; - - var Domain = $('#wprestoresubdirdomain').val() - var path = $('#wprestoresubdirpath').val(); - var home = "1"; - - if (typeof path != 'undefined' || path != '') { - home = "0"; - } - if (typeof path == 'undefined') { - path = ""; - } - - - var backuptype = $('#backuptype').html(); - var data; - if (backuptype == "DataBase Backup") { - data = { - backupid: $('#backupid').html(), - DesSite: $('#DesSite').children("option:selected").val(), - Domain: '', - path: path, - home: home, - } - } else { - data = { - backupid: $('#backupid').html(), - DesSite: $('#DesSite').children("option:selected").val(), - Domain: Domain, - path: path, - home: home, - } - - } - - var url = "/websites/RestoreWPbackupNow"; - - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - // console.log(data) - - var d = $('#DesSite').children("option:selected").val(); - var c = $("input[name=Newdomain]").val(); - // if (d == -1 || c == "") { - // alert("Please Select Method of Backup Restore"); - // } else { - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - // } - - - function ListInitialDatas(response) { - wordpresshomeloading = true; - $('#wordpresshomeloading').hide(); - - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Restoring process starts!.', - type: 'success' - }); - statusFile = response.data.tempStatusPath; - getCreationStatus(); - - } else { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = false; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $scope.errorMessage = response.data.error_message; - - } - - } - - function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - - } - } - - function getCreationStatus() { - $('#wordpresshomeloading').show(); - - url = "/websites/installWordpressStatus"; - - var data = { - statusFile: statusFile - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - //$('#wordpresshomeloading').hide(); - - if (response.data.abort === 1) { - - if (response.data.installStatus === 1) { - - - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = false; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - - $("#installProgress").css("width", "100%"); - $("#installProgressbackup").css("width", "100%"); - $scope.installPercentage = "100"; - $scope.currentStatus = response.data.currentStatus; - $timeout.cancel(); - - - } else { - - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = false; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $scope.errorMessage = response.data.error_message; - - $("#installProgress").css("width", "0%"); - $("#installProgressbackup").css("width", "0%"); - $scope.installPercentage = "0"; - $scope.goBackDisable = false; - - - } - - } else { - - $("#installProgress").css("width", response.data.installationProgress + "%"); - $("#installProgressbackup").css("width", response.data.installationProgress + "%"); - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - $timeout(getCreationStatus, 1000); - - } - - } - - function cantLoadInitialDatas(response) { - //$('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - } - - $scope.goBack = function () { - $('#wordpresshomeloading').hide(); - $scope.wordpresshomeloading = true; - $scope.stagingDetailsForm = false; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $("#installProgress").css("width", "0%"); - }; -}); - - -//.......................................Remote Backup - -//........... delete DeleteBackupConfigNow - -function DeleteBackupConfigNow(url) { - window.location.href = url; -} - -function DeleteRemoteBackupsiteNow(url) { - window.location.href = url; -} - -function DeleteBackupfileConfigNow(url) { - window.location.href = url; -} - - -app.controller('RemoteBackupConfig', function ($scope, $http, $timeout, $window) { - $scope.RemoteBackupLoading = true; - $scope.SFTPBackUpdiv = true; - - $scope.EndpointURLdiv = true; - $scope.Selectprovider = true; - $scope.S3keyNamediv = true; - $scope.Accesskeydiv = true; - $scope.SecretKeydiv = true; - $scope.SelectRemoteBackuptype = function () { - var val = $scope.RemoteBackuptype; - if (val == "SFTP") { - $scope.SFTPBackUpdiv = false; - $scope.EndpointURLdiv = true; - $scope.Selectprovider = true; - $scope.S3keyNamediv = true; - $scope.Accesskeydiv = true; - $scope.SecretKeydiv = true; - } else if (val == "S3") { - $scope.EndpointURLdiv = true; - $scope.Selectprovider = false; - $scope.S3keyNamediv = false; - $scope.Accesskeydiv = false; - $scope.SecretKeydiv = false; - $scope.SFTPBackUpdiv = true; - } else { - $scope.RemoteBackupLoading = true; - $scope.SFTPBackUpdiv = true; - - $scope.EndpointURLdiv = true; - $scope.Selectprovider = true; - $scope.S3keyNamediv = true; - $scope.Accesskeydiv = true; - $scope.SecretKeydiv = true; - } - } - - $scope.SelectProvidertype = function () { - $scope.EndpointURLdiv = true; - var provider = $scope.Providervalue - if (provider == 'Backblaze') { - $scope.EndpointURLdiv = false; - } else { - $scope.EndpointURLdiv = true; - } - } - - $scope.SaveBackupConfig = function () { - $scope.RemoteBackupLoading = false; - var Hname = $scope.Hostname; - var Uname = $scope.Username; - var Passwd = $scope.Password; - var path = $scope.path; - var type = $scope.RemoteBackuptype; - var Providervalue = $scope.Providervalue; - var data; - if (type == "SFTP") { - - data = { - Hname: Hname, - Uname: Uname, - Passwd: Passwd, - path: path, - type: type - } - } else if (type == "S3") { - if (Providervalue == "Backblaze") { - data = { - S3keyname: $scope.S3keyName, - Provider: Providervalue, - AccessKey: $scope.Accesskey, - SecertKey: $scope.SecretKey, - EndUrl: $scope.EndpointURL, - type: type - } - } else { - data = { - S3keyname: $scope.S3keyName, - Provider: Providervalue, - AccessKey: $scope.Accesskey, - SecertKey: $scope.SecretKey, - type: type - } - - } - - } - var url = "/websites/SaveBackupConfig"; - - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.RemoteBackupLoading = true; - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Successfully Saved!.', - type: 'success' - }); - location.reload(); - - - } else { - new PNotify({ - title: 'Error!', - text: response.data.error_message, - type: 'error' - }); - } - } - - function cantLoadInitialDatas(response) { - $scope.RemoteBackupLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - - } - - - } - -}); - -var UpdatescheduleID; -app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) { - $scope.BackupScheduleLoading = true; - $scope.SaveBackupSchedule = function () { - $scope.RemoteBackupLoading = false; - var FileRetention = $scope.Fretention; - var Backfrequency = $scope.Bfrequency; - - - var data = { - FileRetention: FileRetention, - Backfrequency: Backfrequency, - ScheduleName: $scope.ScheduleName, - RemoteConfigID: $('#RemoteConfigID').html(), - BackupType: $scope.BackupType - } - var url = "/websites/SaveBackupSchedule"; - - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.RemoteBackupLoading = true; - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Successfully Saved!.', - type: 'success' - }); - location.reload(); - - - } else { - new PNotify({ - title: 'Error!', - text: response.data.error_message, - type: 'error' - }); - } - } - - function cantLoadInitialDatas(response) { - $scope.RemoteBackupLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - - } - - - }; - - - $scope.getupdateid = function (ID) { - UpdatescheduleID = ID; - } - - $scope.UpdateRemoteschedules = function () { - $scope.RemoteBackupLoading = false; - var Frequency = $scope.RemoteFrequency; - var fretention = $scope.RemoteFileretention; - - var data = { - ScheduleID: UpdatescheduleID, - Frequency: Frequency, - FileRetention: fretention - } - var url = "/websites/UpdateRemoteschedules"; - - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.RemoteBackupLoading = true; - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Successfully Updated!.', - type: 'success' - }); - location.reload(); - - - } else { - new PNotify({ - title: 'Error!', - text: response.data.error_message, - type: 'error' - }); - } - } - - function cantLoadInitialDatas(response) { - $scope.RemoteBackupLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - - } - }; - - $scope.AddWPsiteforRemoteBackup = function () { - $scope.RemoteBackupLoading = false; - - - var data = { - WpsiteID: $('#Wpsite').val(), - RemoteScheduleID: $('#RemoteScheduleID').html() - } - var url = "/websites/AddWPsiteforRemoteBackup"; - - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.RemoteBackupLoading = true; - if (response.data.status === 1) { - new PNotify({ - title: 'Success!', - text: 'Successfully Saved!.', - type: 'success' - }); - location.reload(); - - - } else { - new PNotify({ - title: 'Error!', - text: response.data.error_message, - type: 'error' - }); - } - } - - function cantLoadInitialDatas(response) { - $scope.RemoteBackupLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type: 'error' - }); - - - } - - - }; -}); -/* 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; - $scope.installationDetailsForm = false; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - - var statusFile; - - $scope.createWebsite = function () { - - $scope.webSiteCreationLoading = false; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - - $scope.currentStatus = "Starting creation.."; - - var ssl, dkimCheck, openBasedir, mailDomain, apacheBackend; - - if ($scope.sslCheck === true) { - ssl = 1; - } else { - ssl = 0 - } - - if ($scope.apacheBackend === true) { - apacheBackend = 1; - } else { - apacheBackend = 0 - } - - if ($scope.dkimCheck === true) { - dkimCheck = 1; - } else { - dkimCheck = 0 - } - - if ($scope.openBasedir === true) { - openBasedir = 1; - } else { - openBasedir = 0 - } - - if ($scope.mailDomain === true) { - mailDomain = 1; - } else { - mailDomain = 0 - } - - url = "/websites/submitWebsiteCreation"; - - var package = $scope.packageForWebsite; - - // 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.domainNameCreate; - // } - var domainName = $scope.domainNameCreate; - - // var domainName = $scope.domainNameCreate; - - var adminEmail = $scope.adminEmail; - var phpSelection = $scope.phpSelection; - var websiteOwner = $scope.websiteOwner; - - - var data = { - package: package, - domainName: domainName, - adminEmail: adminEmail, - phpSelection: phpSelection, - ssl: ssl, - websiteOwner: websiteOwner, - dkimCheck: dkimCheck, - openBasedir: openBasedir, - mailDomain: mailDomain, - apacheBackend: apacheBackend - }; - - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.createWebSiteStatus === 1) { - statusFile = response.data.tempStatusPath; - getCreationStatus(); - } else { - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = false; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $scope.errorMessage = response.data.error_message; - } - - - } - - function cantLoadInitialDatas(response) { - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - }; - $scope.goBack = function () { - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = false; - $scope.installationProgress = true; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = true; - $("#installProgress").css("width", "0%"); - }; - - function getCreationStatus() { - - url = "/websites/installWordpressStatus"; - - var data = { - statusFile: statusFile - }; - - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if (response.data.abort === 1) { - - if (response.data.installStatus === 1) { - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = false; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $("#installProgress").css("width", "100%"); - $scope.installPercentage = "100"; - $scope.currentStatus = response.data.currentStatus; - $timeout.cancel(); - - } else { - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = false; - $scope.success = true; - $scope.couldNotConnect = true; - $scope.goBackDisable = false; - - $scope.errorMessage = response.data.error_message; - - $("#installProgress").css("width", "0%"); - $scope.installPercentage = "0"; - $scope.goBackDisable = false; - - } - - } else { - $("#installProgress").css("width", response.data.installationProgress + "%"); - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - $timeout(getCreationStatus, 1000); - } - - } - - function cantLoadInitialDatas(response) { - - $scope.webSiteCreationLoading = true; - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.errorMessageBox = true; - $scope.success = true; - $scope.couldNotConnect = false; - $scope.goBackDisable = false; - - } - - - } - -}); -/* Java script code to create account ends here */ - -/* Java script code to list accounts */ - -$("#listFail").hide(); - - -app.controller('listWebsites', function ($scope, $http, $window) { - console.log('Initializing listWebsites controller'); - $scope.web = {}; - $scope.WebSitesList = []; - - $scope.currentPage = 1; - $scope.recordsToShow = 10; - - // Initial fetch of websites - $scope.getFurtherWebsitesFromDB = function () { - console.log('Fetching websites from DB'); - var config = { - headers: { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - var data = { - page: $scope.currentPage, - recordsToShow: $scope.recordsToShow - }; - - var dataurl = "/websites/fetchWebsitesList"; - console.log('Making request to:', dataurl); - - $http.post(dataurl, data, config).then(function(response) { - console.log('Received response:', response); - if (response.data.listWebSiteStatus === 1) { - try { - $scope.WebSitesList = JSON.parse(response.data.data); - console.log('Parsed WebSitesList:', $scope.WebSitesList); - $scope.pagination = response.data.pagination; - $("#listFail").hide(); - } catch (e) { - console.error('Error parsing response data:', e); - $("#listFail").fadeIn(); - $scope.errorMessage = 'Error parsing server response'; - } - } else { - $("#listFail").fadeIn(); - $scope.errorMessage = response.data.error_message; } }).catch(function(error) { - console.error('Error fetching websites:', error); $("#listFail").fadeIn(); $scope.errorMessage = error.message || 'An error occurred while fetching websites'; }); @@ -8240,72 +2675,110 @@ app.controller('listWebsites', function ($scope, $http, $window) { $scope.getFurtherWebsitesFromDB(); $scope.showWPSites = function(index) { - console.log('showWPSites called with index:', index); - console.log('Current WebSitesList:', $scope.WebSitesList); - $scope.selectedWebsite = $scope.WebSitesList[index]; - console.log('Selected website:', $scope.selectedWebsite); - // Call the new GetWPSitesByDomain endpoint - var url = '/websites/GetWPSitesByDomain'; - var data = { - domain: $scope.selectedWebsite.domain - }; - - $http({ - method: 'POST', - url: url, - data: JSON.stringify(data), - headers: { - 'Content-Type': 'application/json', - 'X-CSRFToken': getCookie('csrftoken') - } - }).then(function(response) { - console.log('WP Sites Response:', response); + if (!$scope.selectedWebsite.wp_sites) { + var url = '/websites/fetchWPDetails'; + var data = { + domain: $scope.selectedWebsite.domain, + websiteName: $scope.selectedWebsite.domain + }; - if (response.data && response.data.status === 1) { - try { - // Display the data in an alert - var wpSites = response.data.data; - var alertMessage = 'WordPress Sites for ' + $scope.selectedWebsite.domain + ':\n\n'; - - wpSites.forEach(function(site, index) { - alertMessage += 'Site ' + (index + 1) + ':\n'; - alertMessage += 'Title: ' + site.title + '\n'; - alertMessage += 'URL: ' + site.url + '\n'; - alertMessage += 'Version: ' + site.version + '\n'; - alertMessage += 'PHP Version: ' + site.phpVersion + '\n'; - alertMessage += 'Active Plugins: ' + site.activePlugins + '\n'; - alertMessage += 'Theme: ' + site.theme + '\n'; - alertMessage += 'Debugging: ' + (site.debugging ? 'Enabled' : 'Disabled') + '\n'; - alertMessage += 'Search Index: ' + (site.searchIndex ? 'Enabled' : 'Disabled') + '\n'; - alertMessage += 'Maintenance Mode: ' + (site.maintenanceMode ? 'Enabled' : 'Disabled') + '\n'; - alertMessage += 'Password Protection: ' + (site.passwordProtection ? 'Enabled' : 'Disabled') + '\n\n'; - }); - - alert(alertMessage); - - // Update the UI with the data - $scope.selectedWebsite.wp_sites = wpSites; - $scope.selectedWebsite.showWPSites = true; - } catch (e) { - console.error('Error processing WordPress data:', e); - alert('Error processing WordPress data: ' + e.message); - $scope.selectedWebsite.showWPSites = false; - $scope.selectedWebsite.wp_sites = []; + $http({ + method: 'POST', + url: url, + data: $.param(data), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'X-CSRFToken': getCookie('csrftoken') } - } else { - console.error('Error fetching WordPress sites:', response.data.error_message); - alert('Error fetching WordPress sites: ' + response.data.error_message); - $scope.selectedWebsite.showWPSites = false; - $scope.selectedWebsite.wp_sites = []; - } - }, function(error) { - console.error('Error fetching WordPress sites:', error); - alert('Error fetching WordPress sites: ' + error.message); - $scope.selectedWebsite.showWPSites = false; - $scope.selectedWebsite.wp_sites = []; - }); + }).then(function(response) { + console.log('WP Details Response:', response); + + // Check if response is HTML (login page) + if (typeof response.data === 'string' && response.data.includes('')) { + console.log('Received HTML response, redirecting to login'); + window.location.href = '/login'; + return; + } + + if (response.data && response.data.status === 1) { + try { + // If single site, wrap in array + var sites = Array.isArray(response.data.data) ? response.data.data : [response.data.data]; + + $scope.selectedWebsite.wp_sites = sites.map(function(site) { + return { + id: site.id || $scope.selectedWebsite.domain, + title: site.title || site.domain || $scope.selectedWebsite.domain, + url: site.url || 'http://' + $scope.selectedWebsite.domain, + version: site.version || 'Unknown', + phpVersion: site.php_version || 'Unknown', + theme: site.theme || 'Unknown', + activePlugins: site.active_plugins || 0, + searchIndex: site.search_index === 'enabled', + debugging: site.debugging === 'enabled', + passwordProtection: site.password_protection === 'enabled', + maintenanceMode: site.maintenance_mode === 'enabled' + }; + }); + $scope.selectedWebsite.showWPSites = true; + } catch (e) { + console.error('Error processing WordPress data:', e); + // Create default site on error + $scope.selectedWebsite.wp_sites = [{ + id: $scope.selectedWebsite.domain, + title: $scope.selectedWebsite.domain, + url: 'http://' + $scope.selectedWebsite.domain, + version: 'Unknown', + phpVersion: 'Unknown', + theme: 'Unknown', + activePlugins: 0, + searchIndex: false, + debugging: false, + passwordProtection: false, + maintenanceMode: false + }]; + $scope.selectedWebsite.showWPSites = true; + } + } else { + // Create default site if no data + $scope.selectedWebsite.wp_sites = [{ + id: $scope.selectedWebsite.domain, + title: $scope.selectedWebsite.domain, + url: 'http://' + $scope.selectedWebsite.domain, + version: 'Unknown', + phpVersion: 'Unknown', + theme: 'Unknown', + activePlugins: 0, + searchIndex: false, + debugging: false, + passwordProtection: false, + maintenanceMode: false + }]; + $scope.selectedWebsite.showWPSites = true; + } + }).catch(function(error) { + console.error('WP Details Error:', error); + // Create default site on error + $scope.selectedWebsite.wp_sites = [{ + id: $scope.selectedWebsite.domain, + title: $scope.selectedWebsite.domain, + url: 'http://' + $scope.selectedWebsite.domain, + version: 'Unknown', + phpVersion: 'Unknown', + theme: 'Unknown', + activePlugins: 0, + searchIndex: false, + debugging: false, + passwordProtection: false, + maintenanceMode: false + }]; + $scope.selectedWebsite.showWPSites = true; + }); + } else { + $scope.selectedWebsite.showWPSites = !$scope.selectedWebsite.showWPSites; + } }; $scope.visitSite = function(url) { @@ -12176,72 +6649,110 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind } $scope.showWPSites = function(index) { - console.log('showWPSites called with index:', index); - console.log('Current WebSitesList:', $scope.WebSitesList); - $scope.selectedWebsite = $scope.WebSitesList[index]; - console.log('Selected website:', $scope.selectedWebsite); - // Call the new GetWPSitesByDomain endpoint - var url = '/websites/GetWPSitesByDomain'; + if (!$scope.selectedWebsite.wp_sites) { + var url = '/websites/fetchWPDetails'; var data = { - domain: $scope.selectedWebsite.domain + domain: $scope.selectedWebsite.domain, + websiteName: $scope.selectedWebsite.domain }; - - $http({ - method: 'POST', - url: url, - data: JSON.stringify(data), + + $http({ + method: 'POST', + url: url, + data: $.param(data), headers: { - 'Content-Type': 'application/json', + 'Content-Type': 'application/x-www-form-urlencoded', 'X-CSRFToken': getCookie('csrftoken') } - }).then(function(response) { - console.log('WP Sites Response:', response); - - if (response.data && response.data.status === 1) { - try { - // Display the data in an alert - var wpSites = response.data.data; - var alertMessage = 'WordPress Sites for ' + $scope.selectedWebsite.domain + ':\n\n'; - - wpSites.forEach(function(site, index) { - alertMessage += 'Site ' + (index + 1) + ':\n'; - alertMessage += 'Title: ' + site.title + '\n'; - alertMessage += 'URL: ' + site.url + '\n'; - alertMessage += 'Version: ' + site.version + '\n'; - alertMessage += 'PHP Version: ' + site.phpVersion + '\n'; - alertMessage += 'Active Plugins: ' + site.activePlugins + '\n'; - alertMessage += 'Theme: ' + site.theme + '\n'; - alertMessage += 'Debugging: ' + (site.debugging ? 'Enabled' : 'Disabled') + '\n'; - alertMessage += 'Search Index: ' + (site.searchIndex ? 'Enabled' : 'Disabled') + '\n'; - alertMessage += 'Maintenance Mode: ' + (site.maintenanceMode ? 'Enabled' : 'Disabled') + '\n'; - alertMessage += 'Password Protection: ' + (site.passwordProtection ? 'Enabled' : 'Disabled') + '\n\n'; - }); - - alert(alertMessage); - - // Update the UI with the data - $scope.selectedWebsite.wp_sites = wpSites; - $scope.selectedWebsite.showWPSites = true; - } catch (e) { - console.error('Error processing WordPress data:', e); - alert('Error processing WordPress data: ' + e.message); - $scope.selectedWebsite.showWPSites = false; - $scope.selectedWebsite.wp_sites = []; + }).then(function(response) { + console.log('WP Details Response:', response); + + // Check if response is HTML (login page) + if (typeof response.data === 'string' && response.data.includes('')) { + console.log('Received HTML response, redirecting to login'); + window.location.href = '/login'; + return; } + + if (response.data && response.data.status === 1) { + try { + // If single site, wrap in array + var sites = Array.isArray(response.data.data) ? response.data.data : [response.data.data]; + + $scope.selectedWebsite.wp_sites = sites.map(function(site) { + return { + id: site.id || $scope.selectedWebsite.domain, + title: site.title || site.domain || $scope.selectedWebsite.domain, + url: site.url || 'http://' + $scope.selectedWebsite.domain, + version: site.version || 'Unknown', + phpVersion: site.php_version || 'Unknown', + theme: site.theme || 'Unknown', + activePlugins: site.active_plugins || 0, + searchIndex: site.search_index === 'enabled', + debugging: site.debugging === 'enabled', + passwordProtection: site.password_protection === 'enabled', + maintenanceMode: site.maintenance_mode === 'enabled' + }; + }); + $scope.selectedWebsite.showWPSites = true; + } catch(e) { + console.error('Error processing WordPress data:', e); + // Create default site on error + $scope.selectedWebsite.wp_sites = [{ + id: $scope.selectedWebsite.domain, + title: $scope.selectedWebsite.domain, + url: 'http://' + $scope.selectedWebsite.domain, + version: 'Unknown', + phpVersion: 'Unknown', + theme: 'Unknown', + activePlugins: 0, + searchIndex: false, + debugging: false, + passwordProtection: false, + maintenanceMode: false + }]; + $scope.selectedWebsite.showWPSites = true; + } } else { - console.error('Error fetching WordPress sites:', response.data.error_message); - alert('Error fetching WordPress sites: ' + response.data.error_message); - $scope.selectedWebsite.showWPSites = false; - $scope.selectedWebsite.wp_sites = []; - } - }, function(error) { - console.error('Error fetching WordPress sites:', error); - alert('Error fetching WordPress sites: ' + error.message); - $scope.selectedWebsite.showWPSites = false; - $scope.selectedWebsite.wp_sites = []; - }); + // Create default site if no data + $scope.selectedWebsite.wp_sites = [{ + id: $scope.selectedWebsite.domain, + title: $scope.selectedWebsite.domain, + url: 'http://' + $scope.selectedWebsite.domain, + version: 'Unknown', + phpVersion: 'Unknown', + theme: 'Unknown', + activePlugins: 0, + searchIndex: false, + debugging: false, + passwordProtection: false, + maintenanceMode: false + }]; + $scope.selectedWebsite.showWPSites = true; + } + }).catch(function(error) { + console.error('WP Details Error:', error); + // Create default site on error + $scope.selectedWebsite.wp_sites = [{ + id: $scope.selectedWebsite.domain, + title: $scope.selectedWebsite.domain, + url: 'http://' + $scope.selectedWebsite.domain, + version: 'Unknown', + phpVersion: 'Unknown', + theme: 'Unknown', + activePlugins: 0, + searchIndex: false, + debugging: false, + passwordProtection: false, + maintenanceMode: false + }]; + $scope.selectedWebsite.showWPSites = true; + }); + } else { + $scope.selectedWebsite.showWPSites = !$scope.selectedWebsite.showWPSites; + } }; $scope.updateSetting = function(wp, setting) { @@ -13631,8 +8142,8 @@ app.controller('installMauticCTRL', function ($scope, $http, $timeout) { $scope.installationDetailsForm = true; $scope.installationProgress = false; - $scope.installationFailed = false; - $scope.installationSuccessfull = true; + $scope.installationFailed = true; + $scope.installationSuccessfull = false; $scope.couldNotConnect = true; $scope.wpInstallLoading = true; $scope.goBackDisable = false; diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py index 285f16931..9469ca672 100755 --- a/websiteFunctions/urls.py +++ b/websiteFunctions/urls.py @@ -194,6 +194,4 @@ urlpatterns = [ # Catch all for domains path('/', views.launchChild, name='launchChild'), path('', views.domain, name='domain'), - - path(r'GetWPSitesByDomain', views.GetWPSitesByDomain, name='GetWPSitesByDomain'), ] diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index 70e6b3dc4..bcefc8a77 100755 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -1841,21 +1841,4 @@ def Dockersitehome(request, dockerapp): wm = WebsiteManager(dockerapp) return wm.Dockersitehome(request, userID, None) except KeyError: - return redirect(loadLoginPage) - -def GetWPSitesByDomain(request): - try: - userID = request.session['userID'] - data = json.loads(request.body) - domain = data['domain'] - - wm = WebsiteManager() - response = wm.GetWPSitesByDomain(userID, data) - - return response - except KeyError: - return redirect(reverse('login')) - except BaseException as msg: - data_ret = {'status': 0, 'error_message': str(msg)} - json_data = json.dumps(data_ret) - return HttpResponse(json_data) \ No newline at end of file + return redirect(loadLoginPage) \ No newline at end of file diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 7b5f3402c..e2e6c08e6 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -1235,7 +1235,25 @@ class WebsiteManager: admin = Administrator.objects.get(pk=userID) backupid = data['backupid'] - DesSiteID = data['DesSiteID'] + 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'] @@ -1931,7 +1949,7 @@ class WebsiteManager: 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 @@ -1972,60 +1990,1494 @@ AuthUserFile {htpasswd} Require valid-user""" with open(htaccess, 'w') as f: f.write(htaccess_content) - - data_ret = {'status': 1, 'error_message': 'None'} - json_data = json.dumps(data_ret) - return HttpResponse(json_data) + else: + # Disable password protection + if os.path.exists(path): + import shutil + shutil.rmtree(path) + htaccess = f'{wpsite.path}/.htaccess' + if os.path.exists(htaccess): + os.remove(htaccess) + return JsonResponse({'status': 1, 'error_message': 'None'}) + elif setting == 'maintenance-mode': + if value: + command = f'sudo -u {Vhuser} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp maintenance-mode activate --skip-plugins --skip-themes --path={wpsite.path}' + else: + command = f'sudo -u {Vhuser} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp maintenance-mode deactivate --skip-plugins --skip-themes --path={wpsite.path}' + else: + return JsonResponse({'status': 0, 'error_message': 'Invalid setting type'}) + + result = ProcessUtilities.outputExecutioner(command) + if result.find('Error:') > -1: + return JsonResponse({'status': 0, 'error_message': result}) + + return JsonResponse({'status': 1, 'error_message': 'None'}) except BaseException as msg: - data_ret = {'status': 0, 'error_message': str(msg)} - json_data = json.dumps(data_ret) - return HttpResponse(json_data) + return JsonResponse({'status': 0, 'error_message': str(msg)}) - def GetWPSitesByDomain(self, userID=None, data=None): + def submitWorpressCreation(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) - - domain = data['domain'] - website = Websites.objects.get(domain=domain) - - if ACLManager.checkOwnership(domain, admin, currentACL) == 1: + + extraArgs = {} + extraArgs['currentACL'] = currentACL + extraArgs['adminID'] = admin.pk + extraArgs['domainName'] = data['domain'] + extraArgs['WPVersion'] = data['WPVersion'] + extraArgs['blogTitle'] = data['title'] + try: + extraArgs['pluginbucket'] = data['pluginbucket'] + except: + extraArgs['pluginbucket'] = '-1' + extraArgs['adminUser'] = data['adminUser'] + extraArgs['PasswordByPass'] = data['PasswordByPass'] + extraArgs['adminPassword'] = data['PasswordByPass'] + extraArgs['adminEmail'] = data['Email'] + extraArgs['updates'] = data['AutomaticUpdates'] + extraArgs['Plugins'] = data['Plugins'] + extraArgs['Themes'] = data['Themes'] + extraArgs['websiteOwner'] = data['websiteOwner'] + extraArgs['package'] = data['package'] + extraArgs['home'] = data['home'] + extraArgs['apacheBackend'] = data['apacheBackend'] + try: + extraArgs['path'] = data['path'] + if extraArgs['path'] == '': + extraArgs['home'] = '1' + except: + pass + extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) + + background = ApplicationInstaller('wordpressInstallNew', 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 submitWebsiteCreation(self, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + + domain = data['domainName'] + adminEmail = data['adminEmail'] + phpSelection = data['phpSelection'] + 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) + + if ACLManager.currentContextPermission(currentACL, 'createWebsite') == 0: + return ACLManager.loadErrorJson('createWebSiteStatus', 0) + + if ACLManager.checkOwnerProtection(currentACL, loggedUser, newOwner) == 0: + return ACLManager.loadErrorJson('createWebSiteStatus', 0) + + if currentACL['admin'] == 0: + if ACLManager.CheckDomainBlackList(domain) == 0: + data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Blacklisted domain."} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + if not validators.domain(domain): + data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} + 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) + return HttpResponse(json_data) + + try: + HA = data['HA'] + externalApp = 'nobody' + except: + externalApp = "".join(re.findall("[a-zA-Z]+", domain))[:5] + str(randint(1000, 9999)) + + try: + counter = 0 + while 1: + tWeb = Websites.objects.get(externalApp=externalApp) + externalApp = '%s%s' % (tWeb.externalApp, str(counter)) + counter = counter + 1 + except: + pass + + tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999)) + + try: + apacheBackend = str(data['apacheBackend']) + except: + apacheBackend = "0" + + try: + mailDomain = str(data['mailDomain']) + except: + mailDomain = "1" + + import pwd + counter = 0 + + ## Create Configurations + + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = execPath + " createVirtualHost --virtualHostName " + domain + \ + " --administratorEmail " + adminEmail + " --phpVersion '" + phpSelection + \ + "' --virtualHostUser " + externalApp + " --ssl " + str(1) + " --dkimCheck " \ + + str(1) + " --openBasedir " + str(data['openBasedir']) + \ + ' --websiteOwner "' + websiteOwner + '" --package "' + packageName + '" --tempStatusPath ' + tempStatusPath + " --apache " + apacheBackend + " --mailDomain %s" % ( + mailDomain) + + ProcessUtilities.popenExecutioner(execPath) + time.sleep(2) + + data_ret = {'status': 1, 'createWebSiteStatus': 1, 'error_message': "None", + 'tempStatusPath': tempStatusPath, 'LinuxUser': externalApp} + 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 submitDomainCreation(self, userID=None, data=None): + try: + + currentACL = ACLManager.loadedACL(userID) + admin = Administrator.objects.get(pk=userID) + + try: + alias = data['alias'] + except: + alias = 0 + + masterDomain = data['masterDomain'] + domain = data['domainName'] + + + if alias == 0: + phpSelection = data['phpSelection'] + path = data['path'] + else: + + ### if master website have apache then create this sub-domain also as ols + apache + + apachePath = ApacheVhost.configBasePath + masterDomain + '.conf' + + if os.path.exists(apachePath): + data['apacheBackend'] = 1 + + phpSelection = Websites.objects.get(domain=masterDomain).phpSelection + + tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999)) + + if not validators.domain(domain): + data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."} + 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: + return ACLManager.loadErrorJson('createWebSiteStatus', 0) + + if data['path'].find('..') > -1: + return ACLManager.loadErrorJson('createWebSiteStatus', 0) + + if currentACL['admin'] != 1: + data['openBasedir'] = 1 + + if alias == 0: + + if len(path) > 0: + path = path.lstrip("/") + path = "/home/" + masterDomain + "/" + path + else: + path = "/home/" + masterDomain + "/" + domain + else: + path = f'/home/{masterDomain}/public_html' + + try: + apacheBackend = str(data['apacheBackend']) + except: + apacheBackend = "0" + + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + + execPath = execPath + " createDomain --masterDomain " + masterDomain + " --virtualHostName " + domain + \ + " --phpVersion '" + phpSelection + "' --ssl " + str(1) + " --dkimCheck " + str(1) \ + + " --openBasedir " + str(data['openBasedir']) + ' --path ' + path + ' --websiteOwner ' \ + + admin.userName + ' --tempStatusPath ' + tempStatusPath + " --apache " + apacheBackend + f' --aliasDomain {str(alias)}' + + ProcessUtilities.popenExecutioner(execPath) + time.sleep(2) + + data_ret = {'status': 1, 'createWebSiteStatus': 1, 'error_message': "None", + 'tempStatusPath': tempStatusPath} + 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 fetchDomains(self, userID=None, data=None): + try: + + currentACL = ACLManager.loadedACL(userID) + admin = Administrator.objects.get(pk=userID) + masterDomain = data['masterDomain'] + + try: + alias = data['alias'] + except: + alias = 0 + + if ACLManager.checkOwnership(masterDomain, admin, currentACL) == 1: pass else: return ACLManager.loadErrorJson('fetchStatus', 0) - - # Get all WordPress sites for this website + + cdManager = ChildDomainManager(masterDomain) + json_data = cdManager.findChildDomainsJson(alias) + + final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) + return HttpResponse(final_json) + + except BaseException as msg: + final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + + def searchWebsites(self, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + try: + json_data = self.searchWebsitesJson(currentACL, userID, data['patternAdded']) + except BaseException as msg: + tempData = {} + tempData['page'] = 1 + return self.getFurtherAccounts(userID, tempData) + + pagination = self.websitePagination(currentACL, userID) + final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data, + 'pagination': pagination} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except BaseException as msg: + dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + def searchChilds(self, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + + websites = ACLManager.findWebsiteObjects(currentACL, userID) + childDomains = [] + + for web in websites: + for child in web.childdomains_set.filter(domain__istartswith=data['patternAdded']): + childDomains.append(child) + + json_data = self.findChildsListJson(childDomains) + + final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except BaseException as msg: + dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + def getFurtherAccounts(self, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + pageNumber = int(data['page']) + json_data = self.findWebsitesJson(currentACL, userID, pageNumber) + pagination = self.websitePagination(currentACL, userID) + final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data, + 'pagination': pagination} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except BaseException as msg: + dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + def fetchWebsitesList(self, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + pageNumber = int(data['page']) + recordsToShow = int(data['recordsToShow']) + + if os.path.exists(ProcessUtilities.debugPath): + logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 1..') + + endPageNumber, finalPageNumber = self.recordsPointer(pageNumber, recordsToShow) + + if os.path.exists(ProcessUtilities.debugPath): + logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 2..') + + websites = ACLManager.findWebsiteObjects(currentACL, userID) + + if os.path.exists(ProcessUtilities.debugPath): + logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 3..') + + pagination = self.getPagination(len(websites), recordsToShow) + + if os.path.exists(ProcessUtilities.debugPath): + logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 4..') + + json_data = self.findWebsitesListJson(websites[finalPageNumber:endPageNumber]) + + if os.path.exists(ProcessUtilities.debugPath): + logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 5..') + + final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data, + 'pagination': pagination} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except BaseException as msg: + dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + def fetchChildDomainsMain(self, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + pageNumber = int(data['page']) + recordsToShow = int(data['recordsToShow']) + + endPageNumber, finalPageNumber = self.recordsPointer(pageNumber, recordsToShow) + websites = ACLManager.findWebsiteObjects(currentACL, userID) + childDomains = [] + + for web in websites: + for child in web.childdomains_set.filter(alais=0): + if child.domain == f'mail.{web.domain}': + pass + else: + childDomains.append(child) + + pagination = self.getPagination(len(childDomains), recordsToShow) + json_data = self.findChildsListJson(childDomains[finalPageNumber:endPageNumber]) + + final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data, + 'pagination': pagination} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except BaseException as msg: + dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(dic) + return HttpResponse(json_data) + + def findWebsitesListJson(self, websites): + try: + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + ipAddress = ipData.split('\n', 1)[0] + except BaseException as msg: + logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) + ipAddress = "192.168.100.1" + + json_data = [] + + for website in websites: wp_sites = [] - for wp in website.wp_sites.all(): - site_data = { + try: + wp_sites = WPSites.objects.filter(owner=website) + wp_sites = [{ '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) + 'url': wp.FinalURL, + 'version': wp.version if hasattr(wp, 'version') else 'Unknown', + 'phpVersion': wp.phpVersion if hasattr(wp, 'phpVersion') else 'Unknown' + } for wp in wp_sites] + except: + pass + + # Calculate disk usage + DiskUsage, DiskUsagePercentage, bwInMB, bwUsage = virtualHostUtilities.FindStats(website) + diskUsed = "%sMB" % str(DiskUsage) + + # Convert numeric state to text + state = "Active" if website.state == 1 else "Suspended" + + json_data.append({ + 'domain': website.domain, + 'adminEmail': website.adminEmail, + 'phpVersion': website.phpSelection, + 'state': state, + 'ipAddress': ipAddress, + 'package': website.package.packageName, + 'admin': website.admin.userName, + 'wp_sites': wp_sites, + 'diskUsed': diskUsed + }) + return json.dumps(json_data) + + + + def findDockersitesListJson(self, Dockersite): + + json_data = "[" + checker = 0 + + try: + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + ipAddress = ipData.split('\n', 1)[0] except BaseException as msg: - data_ret = {'status': 0, 'error_message': str(msg)} + logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) + ipAddress = "192.168.100.1" + + from plogical.phpUtilities import phpUtilities + for items in Dockersite: + website = Websites.objects.get(pk=items.admin.pk) + vhFile = f'/usr/local/lsws/conf/vhosts/{website.domain}/vhost.conf' + + try: + PHPVersionActual = phpUtilities.WrapGetPHPVersionFromFileToGetVersionWithPHP(website) + except: + PHPVersionActual = 'PHP 8.1' + + + if items.state == 0: + state = "Suspended" + else: + state = "Active" + + dpkg = PackageAssignment.objects.get(user=website.admin) + + + dic = {'id':items.pk, 'domain': website.domain, 'adminEmail': website.adminEmail, 'ipAddress': ipAddress, + 'admin': website.admin.userName, 'package': dpkg.package.Name, 'state': state, + 'CPU': int(items.CPUsMySQL)+int(items.CPUsSite), 'Ram': int(items.MemorySite)+int(items.MemoryMySQL), 'phpVersion': PHPVersionActual } + + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + + json_data = json_data + ']' + + return json_data + + def findChildsListJson(self, childs): + + json_data = "[" + checker = 0 + + try: + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + ipAddress = ipData.split('\n', 1)[0] + except BaseException as msg: + logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) + ipAddress = "192.168.100.1" + + for items in childs: + + dic = {'domain': items.domain, 'masterDomain': items.master.domain, 'adminEmail': items.master.adminEmail, + 'ipAddress': ipAddress, + 'admin': items.master.admin.userName, 'package': items.master.package.packageName, + 'path': items.path} + + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + + json_data = json_data + ']' + + return json_data + + def recordsPointer(self, page, toShow): + finalPageNumber = ((page * toShow)) - toShow + endPageNumber = finalPageNumber + toShow + return endPageNumber, finalPageNumber + + def getPagination(self, records, toShow): + pages = float(records) / float(toShow) + + pagination = [] + counter = 1 + + if pages <= 1.0: + pages = 1 + pagination.append(counter) + else: + pages = ceil(pages) + finalPages = int(pages) + 1 + + for i in range(1, finalPages): + pagination.append(counter) + counter = counter + 1 + + return pagination + + 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: + return ACLManager.loadErrorJson('websiteDeleteStatus', 0) + + websiteName = data['websiteName'] + + admin = Administrator.objects.get(pk=userID) + if ACLManager.checkOwnership(websiteName, admin, currentACL) == 1: + pass + else: + return ACLManager.loadErrorJson('websiteDeleteStatus', 0) + + ## Deleting master domain + + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = execPath + " deleteVirtualHostConfigurations --virtualHostName " + websiteName + ProcessUtilities.popenExecutioner(execPath) + + ### delete site from dgdrive backups + + try: + + from websiteFunctions.models import GDriveSites + GDriveSites.objects.filter(domain=websiteName).delete() + except: + pass + + data_ret = {'status': 1, 'websiteDeleteStatus': 1, 'error_message': "None"} json_data = json.dumps(data_ret) return HttpResponse(json_data) + except BaseException as msg: + data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + 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'] + + try: + DeleteDocRoot = int(data['DeleteDocRoot']) + except: + DeleteDocRoot = 0 + + if ACLManager.checkOwnership(websiteName, admin, currentACL) == 1: + pass + else: + return ACLManager.loadErrorJson('websiteDeleteStatus', 0) + + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = execPath + " deleteDomain --virtualHostName " + websiteName + ' --DeleteDocRoot %s' % ( + str(DeleteDocRoot)) + ProcessUtilities.outputExecutioner(execPath) + + data_ret = {'status': 1, 'websiteDeleteStatus': 1, 'error_message': "None"} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + def submitWebsiteStatus(self, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + if ACLManager.currentContextPermission(currentACL, 'suspendWebsite') == 0: + return ACLManager.loadErrorJson('websiteStatus', 0) + + websiteName = data['websiteName'] + state = data['state'] + + website = Websites.objects.get(domain=websiteName) + + admin = Administrator.objects.get(pk=userID) + if ACLManager.checkOwnership(websiteName, admin, currentACL) == 1: + pass + else: + return ACLManager.loadErrorJson('websiteStatus', 0) + + if state == "Suspend": + confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + websiteName + command = "mv " + confPath + " " + confPath + "-suspended" + ProcessUtilities.popenExecutioner(command) + + childDomains = website.childdomains_set.all() + + for items in childDomains: + confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + items.domain + command = "mv " + confPath + " " + confPath + "-suspended" + ProcessUtilities.executioner(command) + + installUtilities.reStartLiteSpeedSocket() + website.state = 0 + else: + confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + websiteName + + command = "mv " + confPath + "-suspended" + " " + confPath + ProcessUtilities.executioner(command) + + command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + confPath + ProcessUtilities.popenExecutioner(command) + + childDomains = website.childdomains_set.all() + + for items in childDomains: + confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + items.domain + + command = "mv " + confPath + "-suspended" + " " + confPath + ProcessUtilities.executioner(command) + + command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + confPath + ProcessUtilities.popenExecutioner(command) + + installUtilities.reStartLiteSpeedSocket() + website.state = 1 + + website.save() + + data_ret = {'websiteStatus': 1, 'error_message': "None"} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + + data_ret = {'websiteStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + def submitWebsiteModify(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) + 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"} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'saveStatus': 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: @@ -2213,44 +3665,6 @@ Require valid-user""" dic = {'getWebsiteCron': 0, 'error_message': str(msg)} json_data = json.dumps(dic) return HttpResponse(json_data) - - def fetchWebsitesList(self, userID=None, data=None): - try: - currentACL = ACLManager.loadedACL(userID) - pageNumber = int(data['page']) - recordsToShow = int(data['recordsToShow']) - - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 1..') - - endPageNumber, finalPageNumber = self.recordsPointer(pageNumber, recordsToShow) - - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 2..') - - websites = ACLManager.findWebsiteObjects(currentACL, userID) - - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 3..') - - pagination = self.getPagination(len(websites), recordsToShow) - - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 4..') - - json_data = self.findWebsitesListJson(websites[finalPageNumber:endPageNumber]) - - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 5..') - - final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data, - 'pagination': pagination} - final_json = json.dumps(final_dic) - return HttpResponse(final_json) - except BaseException as msg: - dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)} - json_data = json.dumps(dic) - return HttpResponse(json_data) def remCronbyLine(self, userID=None, data=None): try: