diff --git a/static/websiteFunctions/websiteFunctions.js b/static/websiteFunctions/websiteFunctions.js
index 904e2f036..810267b6f 100644
--- a/static/websiteFunctions/websiteFunctions.js
+++ b/static/websiteFunctions/websiteFunctions.js
@@ -568,10 +568,61 @@ app.controller('listWebsites', function ($scope, $http, $window) {
$scope.deleteWPSite = function(wp) {
if (confirm('Are you sure you want to delete this WordPress site? This action cannot be undone.')) {
- window.location.href = '/websites/ListWPSites?DeleteID=' + wp.id;
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+ var data = {
+ wpid: wp.id,
+ domain: wp.domain
+ };
+
+ $http.post('/websites/deleteWordPressSite', data, config).then(
+ function(response) {
+ if (response.data.status === 1) {
+ // Remove the WP site from the list
+ var site = $scope.WebSitesList.find(function(site) {
+ return site.domain === wp.domain;
+ });
+ if (site && site.wp_sites) {
+ site.wp_sites = site.wp_sites.filter(function(wpSite) {
+ return wpSite.id !== wp.id;
+ });
+ }
+ new PNotify({
+ title: 'Success!',
+ text: 'WordPress site deleted successfully.',
+ type: 'success'
+ });
+ } else {
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message || 'Could not delete WordPress site',
+ type: 'error'
+ });
+ }
+ },
+ function(response) {
+ new PNotify({
+ title: 'Error!',
+ text: 'Could not connect to server',
+ type: 'error'
+ });
+ }
+ );
}
};
+ $scope.visitSite = function(wp) {
+ var url = wp.url || wp.domain;
+ if (!url) return '';
+ if (url.startsWith('http://') || url.startsWith('https://')) {
+ return url;
+ }
+ return 'https://' + url;
+ };
+
});
app.controller('listChildDomainsMain', function ($scope, $http, $timeout) {
diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js
index 7ff89acad..331db947f 100755
--- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js
+++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js
@@ -2586,6 +2586,3200 @@ app.controller('createWebsite', function ($scope, $http, $timeout, $window) {
$("#listFail").hide();
+app.controller('listWebsites', function ($scope, $http, $window) {
+ $scope.web = {};
+ $scope.WebSitesList = [];
+
+ $scope.currentPage = 1;
+ $scope.recordsToShow = 10;
+
+ // Initial fetch of websites
+ $scope.getFurtherWebsitesFromDB = function () {
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ var data = {
+ page: $scope.currentPage,
+ recordsToShow: $scope.recordsToShow
+ };
+
+ var dataurl = "/websites/fetchWebsitesList";
+
+ $http.post(dataurl, data, config).then(function(response) {
+ if (response.data.listWebSiteStatus === 1) {
+ $scope.WebSitesList = JSON.parse(response.data.data);
+ $scope.pagination = response.data.pagination;
+ $("#listFail").hide();
+ } else {
+ $("#listFail").fadeIn();
+ $scope.errorMessage = response.data.error_message;
+ }
+ }).catch(function(error) {
+ $("#listFail").fadeIn();
+ $scope.errorMessage = error.message || 'An error occurred while fetching websites';
+ });
+ };
+
+ // Call it immediately
+ $scope.getFurtherWebsitesFromDB();
+
+ $scope.showWPSites = function(domain) {
+ console.log('showWPSites called for domain:', domain);
+
+ // Make sure domain is defined
+ if (!domain) {
+ console.error('Domain is undefined');
+ return;
+ }
+
+ var url = '/websites/fetchWPDetails';
+ var data = {
+ domain: domain
+ };
+
+ console.log('Making request to:', url, 'with data:', data);
+
+ $http({
+ method: 'POST',
+ url: url,
+ data: $.param(data),
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ }).then(function(response) {
+ console.log('Response received:', response);
+ if (response.data.status === 1 && response.data.fetchStatus === 1) {
+ // Find the website in the list and update its properties
+ $scope.WebSitesList.forEach(function(website) {
+ if (website.domain === domain) {
+ website.wp_sites = response.data.sites;
+ website.showWPSites = true;
+ console.log('Updated website:', website);
+ }
+ });
+ $("#listFail").hide();
+ } else {
+ $("#listFail").fadeIn();
+ $scope.errorMessage = response.data.error_message || 'Failed to fetch WordPress sites';
+ console.error('Error in response:', response.data.error_message);
+ }
+ }).catch(function(error) {
+ $("#listFail").fadeIn();
+ $scope.errorMessage = error.message || 'An error occurred while fetching WordPress sites';
+ console.error('Request failed:', error);
+ });
+ };
+
+ $scope.visitSite = function(wp) {
+ var url = wp.url || wp.domain;
+ if (!url) return '';
+ if (url.startsWith('http://') || url.startsWith('https://')) {
+ return url;
+ }
+ return 'https://' + url;
+ };
+
+ $scope.wpLogin = function(wpId) {
+ window.open('/websites/wpLogin?wpID=' + wpId, '_blank');
+ };
+
+ $scope.manageWP = function(wpId) {
+ window.location.href = '/websites/listWPsites?wpID=' + wpId;
+ };
+
+ $scope.getFullUrl = function(url) {
+ console.log('getFullUrl called with:', url);
+ if (!url) {
+ // If no URL is provided, try to use the domain
+ if (this.wp && this.wp.domain) {
+ url = this.wp.domain;
+ } else {
+ return '';
+ }
+ }
+ if (url.startsWith('http://') || url.startsWith('https://')) {
+ return url;
+ }
+ return 'https://' + url;
+ };
+
+ $scope.deleteWPSite = function(wp) {
+ if (confirm('Are you sure you want to delete this WordPress site? This action cannot be undone.')) {
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+ var data = {
+ wpid: wp.id,
+ domain: wp.domain
+ };
+
+ $http.post('/websites/deleteWordPressSite', data, config).then(
+ function(response) {
+ if (response.data.status === 1) {
+ // Remove the WP site from the list
+ var site = $scope.WebSitesList.find(function(site) {
+ return site.domain === wp.domain;
+ });
+ if (site && site.wp_sites) {
+ site.wp_sites = site.wp_sites.filter(function(wpSite) {
+ return wpSite.id !== wp.id;
+ });
+ }
+ new PNotify({
+ title: 'Success!',
+ text: 'WordPress site deleted successfully.',
+ type: 'success'
+ });
+ } else {
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message || 'Could not delete WordPress site',
+ type: 'error'
+ });
+ }
+ },
+ function(response) {
+ new PNotify({
+ title: 'Error!',
+ text: 'Could not connect to server',
+ type: 'error'
+ });
+ }
+ );
+ }
+ };
+
+ $scope.updateSetting = function(wp, setting) {
+ var settingMap = {
+ 'search-indexing': 'searchIndex',
+ 'debugging': 'debugging',
+ 'password-protection': 'passwordProtection',
+ 'maintenance-mode': 'maintenanceMode'
+ };
+
+ // Toggle the state before sending request
+ wp[settingMap[setting]] = wp[settingMap[setting]] === 1 ? 0 : 1;
+
+ var data = {
+ siteId: wp.id,
+ setting: setting,
+ value: wp[settingMap[setting]]
+ };
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post('/websites/UpdateWPSettings', data, config).then(function(response) {
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success',
+ text: 'Setting updated successfully.',
+ type: 'success'
+ });
+ if (setting === 'password-protection' && wp[settingMap[setting]] === 1) {
+ // Show password protection modal if enabling
+ wp.PPUsername = "";
+ wp.PPPassword = "";
+ $scope.currentWP = wp;
+ $('#passwordProtectionModal').modal('show');
+ }
+ } else {
+ // Revert the change if update failed
+ wp[settingMap[setting]] = wp[settingMap[setting]] === 1 ? 0 : 1;
+ new PNotify({
+ title: 'Error',
+ text: response.data.error_message || 'Failed to update setting.',
+ type: 'error'
+ });
+ }
+ }).catch(function(error) {
+ // Revert the change on error
+ wp[settingMap[setting]] = wp[settingMap[setting]] === 1 ? 0 : 1;
+ new PNotify({
+ title: 'Error',
+ text: 'Connection failed while updating setting.',
+ type: 'error'
+ });
+ });
+ };
+
+ $scope.UpdateWPSettings = function(wp) {
+ $('#wordpresshomeloading').show();
+
+ var url = "/websites/UpdateWPSettings";
+ var data = {};
+
+ if (wp.setting === "PasswordProtection") {
+ data = {
+ wpID: wp.id,
+ setting: wp.setting,
+ PPUsername: wp.PPUsername,
+ PPPassword: wp.PPPassword
+ };
+ }
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken'),
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ },
+ transformRequest: function(obj) {
+ var str = [];
+ for(var p in obj)
+ str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
+ return str.join("&");
+ }
+ };
+
+ $http.post(url, data, config).then(function(response) {
+ $('#wordpresshomeloading').hide();
+
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success!',
+ text: 'Successfully Updated!',
+ type: 'success'
+ });
+ if (wp.setting === "PasswordProtection") {
+ location.reload();
+ }
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ if (wp.setting === "PasswordProtection") {
+ location.reload();
+ }
+ }
+ }, function(error) {
+ $('#wordpresshomeloading').hide();
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page',
+ type: 'error'
+ });
+ });
+ };
+
+ $scope.togglePasswordProtection = function(wp) {
+ console.log('togglePasswordProtection called with wp:', wp);
+ if (wp.passwordProtection) {
+ // Show modal for credentials
+ console.log('Password protection enabled, showing modal');
+ wp.PPUsername = "";
+ wp.PPPassword = "";
+ $scope.currentWP = wp; // Store current WP site
+ console.log('Current WP site set to:', $scope.currentWP);
+ $('#passwordProtectionModal').modal('show');
+ } else {
+ // Disable password protection
+ console.log('Password protection disabled, sending update');
+ var data = {
+ wpID: wp.id,
+ setting: 'PasswordProtection',
+ PPUsername: '',
+ PPPassword: ''
+ };
+ console.log('Sending data to UpdateWPSettings:', data);
+ $scope.UpdateWPSettings(data);
+ }
+ };
+
+ $scope.UpdateWPSettings = function(data) {
+ console.log('UpdateWPSettings called with data:', data);
+ $('#wordpresshomeloading').show();
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken'),
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ },
+ transformRequest: function(obj) {
+ var str = [];
+ for(var p in obj)
+ str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
+ return str.join("&");
+ }
+ };
+
+ var url = "/websites/UpdateWPSettings";
+ console.log('Sending POST request to:', url);
+
+ $http.post(url, data, config).then(function(response) {
+ console.log('Received response:', response);
+ $('#wordpresshomeloading').hide();
+
+ if (response.data.status === 1) {
+ console.log('Settings updated successfully');
+ new PNotify({
+ title: 'Success!',
+ text: 'Successfully Updated!',
+ type: 'success'
+ });
+ if (data.setting === "PasswordProtection") {
+ console.log('Reloading page after password protection update');
+ location.reload();
+ }
+ } else {
+ console.log('Update failed:', response.data.error_message);
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message || 'Failed to enable password protection',
+ type: 'error'
+ });
+ // Revert the checkbox state
+ $scope.currentWP.passwordProtection = !$scope.currentWP.passwordProtection;
+ }
+ }, function(error) {
+ console.log('Request failed:', error);
+ $('#wordpresshomeloading').hide();
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page',
+ type: 'error'
+ });
+ // Revert the checkbox state
+ $scope.currentWP.passwordProtection = !$scope.currentWP.passwordProtection;
+ });
+ };
+
+ $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'
+ });
+
+
+ }
+
+
+ };
+
+ // Function to submit password protection from modal
+ $scope.submitPasswordProtection = function() {
+ console.log('submitPasswordProtection function called');
+ console.log('Current WP site:', $scope.currentWP);
+
+ if (!$scope.currentWP) {
+ console.log('Error: No WordPress site selected');
+ new PNotify({
+ title: 'Error!',
+ text: 'No WordPress site selected.',
+ type: 'error'
+ });
+ return;
+ }
+
+ console.log('Username:', $scope.currentWP.PPUsername);
+ console.log('Password:', $scope.currentWP.PPPassword ? '[MASKED]' : 'not set');
+
+ if (!$scope.currentWP.PPUsername || !$scope.currentWP.PPPassword) {
+ console.log('Error: Missing username or password');
+ new PNotify({
+ title: 'Error!',
+ text: 'Please provide both username and password',
+ type: 'error'
+ });
+ return;
+ }
+
+ var data = {
+ siteId: $scope.currentWP.id,
+ setting: 'password-protection',
+ value: 'enable'
+ };
+
+ console.log('Submitting data:', data);
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken'),
+ 'Content-Type': 'application/json'
+ }
+ };
+
+ console.log('Sending request to /websites/UpdateWPSettings');
+ $('#passwordProtectionModal').modal('hide');
+
+ $http.post('/websites/UpdateWPSettings', JSON.stringify(data), config).then(function(response) {
+ console.log('Received response:', response);
+ if (response.data.status === 1) {
+ console.log('Password protection updated successfully');
+ new PNotify({
+ title: 'Success!',
+ text: 'Password protection enabled successfully!',
+ type: 'success'
+ });
+ location.reload();
+ } else {
+ console.log('Failed to update password protection:', response.data.error_message);
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message || 'Failed to enable password protection',
+ type: 'error'
+ });
+ // Revert the checkbox state
+ $scope.currentWP.passwordProtection = !$scope.currentWP.passwordProtection;
+ }
+ }).catch(function(error) {
+ console.log('Request failed:', error);
+ new PNotify({
+ title: 'Error!',
+ text: 'Could not connect to server',
+ type: 'error'
+ });
+ // Revert the checkbox state
+ $scope.currentWP.passwordProtection = !$scope.currentWP.passwordProtection;
+ });
+ };
+
+});
+
+/**
+ * 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;
+ $scope.searchIndex = 0;
+
+ $(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(),
+ };
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data, config).then(function(response) {
+ $scope.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);
+ }
+
+ // Set search index state
+ $scope.searchIndex = response.data.ret_data.searchIndex;
+
+ 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 = '';
+ var mp = $compile(dc)($scope);
+ angular.element(document.getElementById('prsswdprodata')).append(mp);
+ CheckBoxpasssword = 1;
+ } else {
+ var dc = '';
+ $('#prsswdprodata').append(dc);
+ CheckBoxpasssword = 0;
+ }
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+ }, function(error) {
+ $('#wordpresshomeloading').hide();
+ $scope.wordpresshomeloading = true;
+ console.error('Failed to load WP data:', error);
+ });
+ };
+
+ $scope.UpdateWPSettings = function (setting) {
+ $scope.wordpresshomeloading = false;
+ $('#wordpresshomeloading').show();
+
+ var url = "/websites/UpdateWPSettings";
+ var data;
+
+ if (setting === "PasswordProtection") {
+ data = {
+ WPid: $('#WPid').html(),
+ setting: setting,
+ PPUsername: CheckBoxpasssword == 0 ? $scope.PPUsername : '',
+ PPPassword: CheckBoxpasssword == 0 ? $scope.PPPassword : ''
+ };
+ } else {
+ var settingValue;
+ if (setting === 'searchIndex') {
+ $scope.searchIndex = $scope.searchIndex === 1 ? 0 : 1;
+ settingValue = $scope.searchIndex;
+ } else {
+ settingValue = $('#' + setting).is(":checked") ? 1 : 0;
+ }
+ data = {
+ WPid: $('#WPid').html(),
+ setting: setting,
+ settingValue: settingValue
+ };
+ }
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data, config).then(function(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'
+ });
+ // Revert the change on error
+ if (setting === 'searchIndex') {
+ $scope.searchIndex = $scope.searchIndex === 1 ? 0 : 1;
+ }
+ if (setting === "PasswordProtection") {
+ location.reload();
+ }
+ }
+ }, function(error) {
+ $('#wordpresshomeloading').hide();
+ $scope.wordpresshomeloading = true;
+ // Revert the change on error
+ if (setting === 'searchIndex') {
+ $scope.searchIndex = $scope.searchIndex === 1 ? 0 : 1;
+ }
+ console.error('Failed to update setting:', error);
+ });
+ };
+
+ $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 = '