diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js
index 778da2a9f..e6fad7f0f 100755
--- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js
+++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js
@@ -2685,73 +2685,84 @@ app.controller('listWebsites', function ($scope, $http, $window) {
// 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);
-
- // Always fetch fresh data
- var url = '/websites/FetchWPdata';
- var data = {
- domain: $scope.selectedWebsite.domain,
- websiteName: $scope.selectedWebsite.domain
- };
-
- $http({
- method: 'POST',
- url: url,
- data: JSON.stringify(data),
+ $scope.showWPSites = function(domain) {
+ var config = {
headers: {
- 'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
}
- }).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);
- $scope.selectedWebsite.showWPSites = false;
- $scope.selectedWebsite.wp_sites = [];
+ };
+
+ var data = {
+ domain: domain
+ };
+
+ var url = '/websites/GetWPSitesByDomain';
+
+ $http.post(url, data, config).then(function(response) {
+ if (response.data.status === 1) {
+ // Find the website in the list and update its WordPress sites
+ for (var i = 0; i < $scope.WebSitesList.length; i++) {
+ if ($scope.WebSitesList[i].domain === domain) {
+ $scope.WebSitesList[i].wp_sites = response.data.data;
+ $scope.WebSitesList[i].showWPSites = !$scope.WebSitesList[i].showWPSites;
+ break;
+ }
}
} else {
console.error('Error fetching WordPress sites:', response.data.error_message);
- $scope.selectedWebsite.showWPSites = false;
- $scope.selectedWebsite.wp_sites = [];
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message,
+ type: 'error'
+ });
}
}, function(error) {
console.error('Error fetching WordPress sites:', error);
- $scope.selectedWebsite.showWPSites = false;
- $scope.selectedWebsite.wp_sites = [];
+ new PNotify({
+ title: 'Error!',
+ text: 'Failed to fetch WordPress sites. Please try again.',
+ type: 'error'
+ });
+ });
+ };
+
+ $scope.updateSetting = function(wpId, setting, value) {
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ var data = {
+ siteId: wpId,
+ setting: setting,
+ value: value
+ };
+
+ var url = '/websites/UpdateWPSettings';
+
+ $http.post(url, data, config).then(function(response) {
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success!',
+ text: 'Setting updated successfully.',
+ type: 'success'
+ });
+ } else {
+ console.error('Error updating setting:', response.data.error_message);
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+ }, function(error) {
+ console.error('Error updating setting:', error);
+ new PNotify({
+ title: 'Error!',
+ text: 'Failed to update setting. Please try again.',
+ type: 'error'
+ });
});
};
@@ -2767,59 +2778,6 @@ app.controller('listWebsites', function ($scope, $http, $window) {
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) {
@@ -8240,73 +8198,84 @@ app.controller('listWebsites', function ($scope, $http, $window) {
// 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);
-
- // Always fetch fresh data
- var url = '/websites/FetchWPdata';
- var data = {
- domain: $scope.selectedWebsite.domain,
- websiteName: $scope.selectedWebsite.domain
- };
-
- $http({
- method: 'POST',
- url: url,
- data: JSON.stringify(data),
+ $scope.showWPSites = function(domain) {
+ var config = {
headers: {
- 'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
}
- }).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);
- $scope.selectedWebsite.showWPSites = false;
- $scope.selectedWebsite.wp_sites = [];
+ };
+
+ var data = {
+ domain: domain
+ };
+
+ var url = '/websites/GetWPSitesByDomain';
+
+ $http.post(url, data, config).then(function(response) {
+ if (response.data.status === 1) {
+ // Find the website in the list and update its WordPress sites
+ for (var i = 0; i < $scope.WebSitesList.length; i++) {
+ if ($scope.WebSitesList[i].domain === domain) {
+ $scope.WebSitesList[i].wp_sites = response.data.data;
+ $scope.WebSitesList[i].showWPSites = !$scope.WebSitesList[i].showWPSites;
+ break;
+ }
}
} else {
console.error('Error fetching WordPress sites:', response.data.error_message);
- $scope.selectedWebsite.showWPSites = false;
- $scope.selectedWebsite.wp_sites = [];
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message,
+ type: 'error'
+ });
}
}, function(error) {
console.error('Error fetching WordPress sites:', error);
- $scope.selectedWebsite.showWPSites = false;
- $scope.selectedWebsite.wp_sites = [];
+ new PNotify({
+ title: 'Error!',
+ text: 'Failed to fetch WordPress sites. Please try again.',
+ type: 'error'
+ });
+ });
+ };
+
+ $scope.updateSetting = function(wpId, setting, value) {
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ var data = {
+ siteId: wpId,
+ setting: setting,
+ value: value
+ };
+
+ var url = '/websites/UpdateWPSettings';
+
+ $http.post(url, data, config).then(function(response) {
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success!',
+ text: 'Setting updated successfully.',
+ type: 'success'
+ });
+ } else {
+ console.error('Error updating setting:', response.data.error_message);
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+ }, function(error) {
+ console.error('Error updating setting:', error);
+ new PNotify({
+ title: 'Error!',
+ text: 'Failed to update setting. Please try again.',
+ type: 'error'
+ });
});
};
@@ -8322,59 +8291,6 @@ app.controller('listWebsites', function ($scope, $http, $window) {
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) {
@@ -12177,124 +12093,82 @@ 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);
-
- // Always fetch fresh data
- var url = '/websites/FetchWPdata';
- var data = {
- domain: $scope.selectedWebsite.domain,
- websiteName: $scope.selectedWebsite.domain
- };
-
- $http({
- method: 'POST',
- url: url,
- data: JSON.stringify(data),
+ $scope.showWPSites = function(domain) {
+ var config = {
headers: {
- 'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken')
}
- }).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);
- $scope.selectedWebsite.showWPSites = false;
- $scope.selectedWebsite.wp_sites = [];
+ };
+
+ var data = {
+ domain: domain
+ };
+
+ var url = '/websites/GetWPSitesByDomain';
+
+ $http.post(url, data, config).then(function(response) {
+ if (response.data.status === 1) {
+ // Find the website in the list and update its WordPress sites
+ for (var i = 0; i < $scope.WebSitesList.length; i++) {
+ if ($scope.WebSitesList[i].domain === domain) {
+ $scope.WebSitesList[i].wp_sites = response.data.data;
+ $scope.WebSitesList[i].showWPSites = !$scope.WebSitesList[i].showWPSites;
+ break;
+ }
}
} else {
console.error('Error fetching WordPress sites:', response.data.error_message);
- $scope.selectedWebsite.showWPSites = false;
- $scope.selectedWebsite.wp_sites = [];
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message,
+ type: 'error'
+ });
}
}, function(error) {
console.error('Error fetching WordPress sites:', error);
- $scope.selectedWebsite.showWPSites = false;
- $scope.selectedWebsite.wp_sites = [];
+ new PNotify({
+ title: 'Error!',
+ text: 'Failed to fetch WordPress sites. Please try again.',
+ type: 'error'
+ });
});
};
- $scope.updateSetting = function(wp, setting) {
- var settingMap = {
- 'search-indexing': 'searchIndex',
- 'debugging': 'debugging',
- 'password-protection': 'passwordProtection',
- 'maintenance-mode': 'maintenanceMode'
+ $scope.updateSetting = function(wpId, setting, value) {
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
};
var data = {
- wpID: wp.id,
+ siteId: wpId,
setting: setting,
- value: wp[settingMap[setting]] ? 'enable' : 'disable'
+ value: value
};
- $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) {
+ var url = '/websites/UpdateWPSettings';
+
+ $http.post(url, data, config).then(function(response) {
if (response.data.status === 1) {
new PNotify({
- title: 'Success',
+ title: 'Success!',
text: 'Setting updated successfully.',
type: 'success'
});
} else {
- wp[settingMap[setting]] = !wp[settingMap[setting]]; // Revert the change
+ console.error('Error updating setting:', response.data.error_message);
new PNotify({
- title: 'Error',
- text: 'Failed to update setting.',
+ title: 'Error!',
+ text: response.data.error_message,
type: 'error'
});
}
- }).catch(function(error) {
- wp[settingMap[setting]] = !wp[settingMap[setting]]; // Revert the change
+ }, function(error) {
+ console.error('Error updating setting:', error);
new PNotify({
- title: 'Error',
- text: 'Connection failed while updating setting.',
+ title: 'Error!',
+ text: 'Failed to update setting. Please try again.',
type: 'error'
});
});
@@ -12312,73 +12186,15 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
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'
- };
+ $scope.cyberPanelLoading = true;
+
+ $scope.issueSSL = function (virtualHost) {
+ $scope.cyberPanelLoading = false;
+
+ url = "/websites/issueSSL";
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.saveRewriteRules = function () {
-
- $scope.configFileLoading = false;
-
-
- url = "/websites/saveRewriteRules";
-
- var virtualHost = $("#childDomain").text();
- var rewriteRules = $scope.rewriteRules;
-
-
- var data = {
- virtualHost: virtualHost,
- rewriteRules: rewriteRules,
+ virtualHost: virtualHost
};
var config = {
@@ -12389,69 +12205,34 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
$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;
-
-
+ if (response.data.status === 1) {
+ $scope.cyberPanelLoading = true;
+ $scope.sslIssued = false;
+ $scope.couldNotIssueSSL = true;
+ $scope.couldNotConnect = 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.cyberPanelLoading = true;
+ $scope.sslIssued = true;
+ $scope.couldNotIssueSSL = false;
+ $scope.couldNotConnect = 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.cyberPanelLoading = true;
+ $scope.sslIssued = true;
+ $scope.couldNotIssueSSL = true;
$scope.couldNotConnect = false;
-
-
}
-
-
};
-
- //////// SSL Part
-
$scope.sslSaved = true;
$scope.couldNotSaveSSL = true;
$scope.hidsslconfigs = true;
$scope.couldNotConnect = true;
-
$scope.hidesslbtn = function () {
$scope.hidsslconfigs = true;
};
@@ -12463,10 +12244,7 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
$scope.changePHPView = true;
};
-
$scope.saveSSL = function () {
-
-
$scope.configFileLoading = false;
url = "/websites/saveSSL";
@@ -12475,7 +12253,6 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
var cert = $scope.cert;
var key = $scope.key;
-
var data = {
virtualHost: virtualHost,
cert: cert,
@@ -12490,53 +12267,34 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
$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;
};
@@ -12548,11 +12306,7 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
$scope.changePHPView = false;
};
-
$scope.changePHPVersionMaster = function (childDomain, phpSelection) {
-
- // notifcations
-
$scope.configFileLoading = false;
var url = "/websites/changePHP";
@@ -12570,63 +12324,36 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
function ListInitialDatas(response) {
-
-
if (response.data.changePHP === 1) {
-
$scope.configFileLoading = true;
$scope.websiteDomain = $("#childDomain").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;
-
}
-
};
-
- /// Open_basedir protection
-
$scope.baseDirLoading = true;
$scope.operationFailed = true;
$scope.operationSuccessfull = true;
$scope.couldNotConnect = true;
$scope.openBaseDirBox = true;
-
$scope.openBaseDirView = function () {
$scope.openBaseDirBox = false;
};
@@ -12636,16 +12363,12 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
};
$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 = {
@@ -12661,52 +12384,36 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
$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;
-
-
}
-
}
-
});
/* Application Installer */
app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
-
$scope.installationDetailsForm = false;
$scope.installationProgress = true;
$scope.installationFailed = true;
@@ -12719,7 +12426,6 @@ app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
var domain = $("#domainNamePage").text();
var path;
-
$scope.goBack = function () {
$scope.installationDetailsForm = false;
$scope.installationProgress = true;
@@ -12732,7 +12438,6 @@ app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
};
$scope.installWordPress = function () {
-
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.installationFailed = true;
@@ -12744,7 +12449,6 @@ app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
path = $scope.installPath;
-
url = "/websites/installWordpress";
var home = "1";
@@ -12753,7 +12457,6 @@ app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
home = "0";
}
-
var data = {
domain: domain,
home: home,
@@ -12772,14 +12475,11 @@ app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
function ListInitialDatas(response) {
-
if (response.data.installStatus === 1) {
statusFile = response.data.tempStatusPath;
getInstallStatus();
} else {
-
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.installationFailed = false;
@@ -12787,23 +12487,15 @@ app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
$scope.couldNotConnect = true;
$scope.wpInstallLoading = true;
$scope.goBackDisable = false;
-
$scope.errorMessage = response.data.error_message;
-
}
-
-
}
function cantLoadInitialDatas(response) {
-
-
}
-
};
function getInstallStatus() {
-
url = "/websites/installWordpressStatus";
var data = {
@@ -12817,17 +12509,11 @@ app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
}
};
-
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
function ListInitialDatas(response) {
-
-
if (response.data.abort === 1) {
-
if (response.data.installStatus === 1) {
-
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.installationFailed = true;
@@ -12842,14 +12528,11 @@ app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
$scope.installationURL = domain;
}
-
$("#installProgress").css("width", "100%");
$scope.installPercentage = "100";
$scope.currentStatus = response.data.currentStatus;
$timeout.cancel();
-
} else {
-
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.installationFailed = false;
@@ -12862,33 +12545,21 @@ app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
$("#installProgress").css("width", "0%");
$scope.installPercentage = "0";
-
}
-
} else {
$("#installProgress").css("width", response.data.installationProgress + "%");
$scope.installPercentage = response.data.installationProgress;
$scope.currentStatus = response.data.currentStatus;
$timeout(getInstallStatus, 1000);
-
-
}
-
}
function cantLoadInitialDatas(response) {
-
$scope.canNotFetch = true;
$scope.couldNotConnect = false;
-
-
}
-
-
}
-
-
});
app.controller('installJoomlaCTRL', function ($scope, $http, $timeout) {
@@ -15077,16 +14748,108 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
}
};
- $scope.fetchGitignore = function () {
-
- $scope.cyberpanelLoading = false;
-
- url = "/websites/fetchGitignore";
-
+ $scope.showWPSites = function(domain) {
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
var data = {
- domain: $("#domain").text(),
- folder: $scope.folder
+ domain: domain
+ };
+
+ var url = '/websites/GetWPSitesByDomain';
+
+ $http.post(url, data, config).then(function(response) {
+ if (response.data.status === 1) {
+ // Find the website in the list and update its WordPress sites
+ for (var i = 0; i < $scope.WebSitesList.length; i++) {
+ if ($scope.WebSitesList[i].domain === domain) {
+ $scope.WebSitesList[i].wp_sites = response.data.data;
+ $scope.WebSitesList[i].showWPSites = !$scope.WebSitesList[i].showWPSites;
+ break;
+ }
+ }
+ } else {
+ console.error('Error fetching WordPress sites:', response.data.error_message);
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+ }, function(error) {
+ console.error('Error fetching WordPress sites:', error);
+ new PNotify({
+ title: 'Error!',
+ text: 'Failed to fetch WordPress sites. Please try again.',
+ type: 'error'
+ });
+ });
+ };
+
+ $scope.updateSetting = function(wpId, setting, value) {
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ var data = {
+ siteId: wpId,
+ setting: setting,
+ value: value
+ };
+
+ var url = '/websites/UpdateWPSettings';
+
+ $http.post(url, data, config).then(function(response) {
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success!',
+ text: 'Setting updated successfully.',
+ type: 'success'
+ });
+ } else {
+ console.error('Error updating setting:', response.data.error_message);
+ new PNotify({
+ title: 'Error!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+ }, function(error) {
+ console.error('Error updating setting:', error);
+ new PNotify({
+ title: 'Error!',
+ text: 'Failed to update setting. Please try again.',
+ type: 'error'
+ });
+ });
+ };
+
+ $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.cyberPanelLoading = true;
+
+ $scope.issueSSL = function (virtualHost) {
+ $scope.cyberPanelLoading = false;
+
+ url = "/websites/issueSSL";
+
+ var data = {
+ virtualHost: virtualHost
};
var config = {
@@ -15098,1051 +14861,65 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
+ $scope.cyberPanelLoading = true;
if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully fetched.',
- type: 'success'
- });
- $scope.gitIgnoreContent = response.data.gitIgnoreContent;
+ $scope.sslIssued = false;
+ $scope.couldNotIssueSSL = true;
+ $scope.couldNotConnect = true;
} 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.saveGitIgnore = function () {
-
- $scope.cyberpanelLoading = false;
-
- url = "/websites/saveGitIgnore";
-
-
- var data = {
- domain: $("#domain").text(),
- folder: $scope.folder,
- gitIgnoreContent: $scope.gitIgnoreContent
-
- };
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully saved.',
- 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.fetchCommits = function () {
-
- $scope.cyberpanelLoading = false;
-
- url = "/websites/fetchCommits";
-
-
- var data = {
- domain: $("#domain").text(),
- folder: $scope.folder
- };
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- $scope.gitCommitsTable = false;
- if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully fetched.',
- type: 'success'
- });
- $scope.commits = JSON.parse(response.data.commits);
- } 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'
- });
-
-
- }
- };
-
- var currentComit;
- var fetchFileCheck = 0;
- var initial = 1;
-
- $scope.fetchFiles = function (commit) {
-
- currentComit = commit;
- $scope.cyberpanelLoading = false;
-
- if (initial === 1) {
- initial = 0;
- } else {
- fetchFileCheck = 1;
- }
-
- url = "/websites/fetchFiles";
-
-
- var data = {
- domain: $("#domain").text(),
- folder: $scope.folder,
- commit: commit
- };
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- $scope.gitCommitsTable = false;
- if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully fetched.',
- type: 'success'
- });
- $scope.files = response.data.files;
- } 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.fileStatus = true;
-
- $scope.fetchChangesInFile = function () {
- $scope.fileStatus = true;
-
- if (fetchFileCheck === 1) {
- fetchFileCheck = 0;
- return 0;
- }
-
- $scope.cyberpanelLoading = false;
- $scope.currentSelectedFile = $scope.changeFile;
-
- url = "/websites/fetchChangesInFile";
-
- var data = {
- domain: $("#domain").text(),
- folder: $scope.folder,
- file: $scope.changeFile,
- commit: currentComit
- };
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully fetched.',
- type: 'success'
- });
- $scope.fileStatus = false;
- document.getElementById("fileChangedContent").innerHTML = response.data.fileChangedContent;
- } else {
- $scope.fileStatus = true;
- new PNotify({
- title: 'Operation Failed!',
- text: response.data.error_message,
- type: 'error'
- });
+ $scope.sslIssued = true;
+ $scope.couldNotIssueSSL = false;
+ $scope.couldNotConnect = true;
+ $scope.errorMessage = response.data.error_message;
}
}
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.sslIssued = true;
+ $scope.couldNotIssueSSL = true;
+ $scope.couldNotConnect = false;
}
};
-
- $scope.saveGitConfigurations = function () {
-
- $scope.cyberpanelLoading = false;
-
- url = "/websites/saveGitConfigurations";
-
- var data = {
- domain: $("#domain").text(),
- folder: $scope.folder,
- autoCommit: $scope.autoCommit,
- autoPush: $scope.autoPush,
- emailLogs: $scope.emailLogs,
- commands: document.getElementById("currentCommands").value,
- webhookCommand: $scope.webhookCommand
- };
-
- if ($scope.autoCommit === undefined) {
- $scope.autoCommitCurrent = 'Never';
- } else {
- $scope.autoCommitCurrent = $scope.autoCommit;
- }
-
- if ($scope.autoPush === undefined) {
- $scope.autoPushCurrent = 'Never';
- } else {
- $scope.autoPushCurrent = $scope.autoPush;
- }
-
- if ($scope.emailLogs === undefined) {
- $scope.emailLogsCurrent = false;
- } else {
- $scope.emailLogsCurrent = $scope.emailLogs;
- }
-
- if ($scope.webhookCommand === undefined) {
- $scope.webhookCommandCurrent = false;
- } else {
- $scope.webhookCommandCurrent = $scope.webhookCommand;
- }
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully saved.',
- 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.currentPage = 1;
- $scope.recordsToShow = 10;
-
- $scope.fetchGitLogs = function () {
- $scope.cyberpanelLoading = false;
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- var data = {
- domain: $("#domain").text(),
- folder: $scope.folder,
- page: $scope.currentPage,
- recordsToShow: $scope.recordsToShow
- };
-
-
- dataurl = "/websites/fetchGitLogs";
-
- $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully fetched.',
- type: 'success'
- });
- $scope.logs = JSON.parse(response.data.logs);
- $scope.pagination = response.data.pagination;
- } 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 git tracking ends here */
+/* Java script code to delete website ends here */
+/* Java script code to modify package ends here */
-app.controller('ApacheManager', function ($scope, $http, $timeout) {
- $scope.cyberpanelloading = true;
- $scope.apacheOLS = true;
- $scope.pureOLS = true;
- $scope.lswsEnt = true;
+/* Java script code to suspend/un-suspend ends here */
- var apache = 1, ols = 2, lsws = 3;
- var statusFile;
+/* Java script code to manage cron */
- $scope.getSwitchStatus = function () {
- $scope.cyberpanelloading = false;
- url = "/websites/getSwitchStatus";
+/* Java script code to manage cron ends here */
- var data = {
- domainName: $("#domainNamePage").text()
- };
+/* Java script code to manage cron */
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
+/* Java script code to syncWebsite ends here */
- $http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
+/* Application Installer */
-
- function ListInitialData(response) {
- $scope.cyberpanelloading = true;
- if (response.data.status === 1) {
- if (response.data.server === apache) {
- $scope.apacheOLS = false;
- $scope.pureOLS = true;
- $scope.lswsEnt = true;
- $scope.configData = response.data.configData;
-
- $scope.pmMaxChildren = response.data.pmMaxChildren;
- $scope.pmStartServers = response.data.pmStartServers;
- $scope.pmMinSpareServers = response.data.pmMinSpareServers;
- $scope.pmMaxSpareServers = response.data.pmMaxSpareServers;
- $scope.phpPath = response.data.phpPath;
-
-
- } else if (response.data.server === ols) {
- $scope.apacheOLS = true;
- $scope.pureOLS = false;
- $scope.lswsEnt = true;
- } else {
- $scope.apacheOLS = true;
- $scope.pureOLS = true;
- $scope.lswsEnt = false;
- }
- //$scope.records = JSON.parse(response.data.data);
- } 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: 'Could not connect to server, please refresh this page.',
- type: 'error'
- });
- }
-
-
- };
- $scope.getSwitchStatus();
-
- $scope.switchServer = function (server) {
- $scope.cyberpanelloading = false;
- $scope.functionProgress = {"width": "0%"};
- $scope.functionStatus = 'Starting conversion..';
-
- url = "/websites/switchServer";
-
- var data = {
- domainName: $("#domainNamePage").text(),
- phpSelection: $scope.phpSelection,
- server: server
- };
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
-
- function ListInitialData(response) {
- if (response.data.status === 1) {
- statusFile = response.data.tempStatusPath;
- statusFunc();
-
- } else {
- $scope.cyberpanelloading = true;
- new PNotify({
- title: 'Operation Failed!',
- text: response.data.error_message,
- type: 'error'
- });
- }
-
- }
-
- function cantLoadInitialData(response) {
- $scope.cyberpanelloading = true;
- new PNotify({
- title: 'Operation Failed!',
- text: 'Could not connect to server, please refresh this page.',
- type: 'error'
- });
- }
-
-
- };
-
- function statusFunc() {
- $scope.cyberpanelloading = false;
- url = "/websites/statusFunc";
-
- var data = {
- statusFile: statusFile
- };
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
-
-
- function ListInitialData(response) {
- if (response.data.status === 1) {
- if (response.data.abort === 1) {
- $scope.functionProgress = {"width": "100%"};
- $scope.functionStatus = response.data.currentStatus;
- $scope.cyberpanelloading = true;
- $timeout.cancel();
- $scope.getSwitchStatus();
- } else {
- $scope.functionProgress = {"width": response.data.installationProgress + "%"};
- $scope.functionStatus = response.data.currentStatus;
- $timeout(statusFunc, 3000);
- }
-
- } else {
- $scope.cyberpanelloading = true;
- $scope.functionStatus = response.data.error_message;
- $scope.functionProgress = {"width": response.data.installationProgress + "%"};
- $timeout.cancel();
- }
-
- }
-
- function cantLoadInitialData(response) {
- $scope.functionProgress = {"width": response.data.installationProgress + "%"};
- $scope.functionStatus = 'Could not connect to server, please refresh this page.';
- $timeout.cancel();
- }
-
- }
-
-
- $scope.tuneSettings = function () {
- $scope.cyberpanelloading = false;
-
- url = "/websites/tuneSettings";
-
- var data = {
- domainName: $("#domainNamePage").text(),
- pmMaxChildren: $scope.pmMaxChildren,
- pmStartServers: $scope.pmStartServers,
- pmMinSpareServers: $scope.pmMinSpareServers,
- pmMaxSpareServers: $scope.pmMaxSpareServers,
- phpPath: $scope.phpPath
- };
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
-
- function ListInitialData(response) {
- $scope.cyberpanelloading = true;
- if (response.data.status === 1) {
-
- new PNotify({
- title: 'Success',
- text: 'Changes successfully applied.',
- type: 'success'
- });
-
- } else {
- $scope.cyberpanelloading = true;
- new PNotify({
- title: 'Operation Failed!',
- text: response.data.error_message,
- type: 'error'
- });
- }
-
- }
-
- function cantLoadInitialData(response) {
- $scope.cyberpanelloading = true;
- new PNotify({
- title: 'Operation Failed!',
- text: 'Could not connect to server, please refresh this page.',
- type: 'error'
- });
- }
-
-
- };
-
- $scope.saveApacheConfig = function () {
- $scope.cyberpanelloading = false;
-
- url = "/websites/saveApacheConfigsToFile";
-
- var data = {
- domainName: $("#domainNamePage").text(),
- configData: $scope.configData
- };
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
-
- function ListInitialData(response) {
- $scope.cyberpanelloading = true;
- if (response.data.status === 1) {
-
- new PNotify({
- title: 'Success',
- text: 'Changes successfully applied.',
- type: 'success'
- });
-
- } else {
- $scope.cyberpanelloading = true;
- new PNotify({
- title: 'Operation Failed!',
- text: response.data.error_message,
- type: 'error'
- });
- }
-
- }
-
- function cantLoadInitialData(response) {
- $scope.cyberpanelloading = true;
- new PNotify({
- title: 'Operation Failed!',
- text: 'Could not connect to server, please refresh this page.',
- type: 'error'
- });
- }
-
-
- };
-
-});
-
-
-app.controller('createDockerPackage', function ($scope, $http, $window) {
- $scope.cyberpanelLoading = true;
-
- $scope.createdockerpackage = function () {
-
- $scope.cyberpanelLoading = false;
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- var data = {
- name: $scope.packagesname,
- cpu: $scope.CPU,
- Memory: $scope.Memory,
- Bandwidth: $scope.Bandwidth,
- disk: $scope.disk
- };
-
-
- dataurl = "/websites/AddDockerpackage";
-
- $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully Saved.',
- 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.Getpackage = function (packid) {
-
- $scope.cyberpanelLoading = false;
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- var data = {
- id: packid,
- };
-
-
- dataurl = "/websites/Getpackage";
-
- $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- if (response.data.status === 1) {
- $scope.U_Name = response.data.error_message.obj.Name
- $scope.U_CPU = response.data.error_message.obj.CPU
- $scope.U_Memory = response.data.error_message.obj.Memory
- $scope.U_Bandwidth = response.data.error_message.obj.Bandwidth
- $scope.U_DiskSpace = response.data.error_message.obj.DiskSpace
-
- $scope.EidtID = packid;
-
- } 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.SaveUpdate = function () {
-
- $scope.cyberpanelLoading = false;
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- var data = {
- id: $scope.EidtID,
- CPU: $scope.U_CPU,
- RAM: $scope.U_Memory,
- Bandwidth: $scope.U_Bandwidth,
- DiskSpace: $scope.U_DiskSpace,
- };
-
-
- dataurl = "/websites/Updatepackage";
-
- $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully Updated.',
- 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'
- });
-
-
- }
- }
-
- var FinalDeletepackageURL;
- $scope.Deletepackage = function (url) {
- FinalDeletepackageURL = url;
- // console.log(FinalDeletepackageURL);
- }
-
- $scope.ConfirmDelete = function () {
- window.location.href = FinalDeletepackageURL
- }
-
-})
-app.controller('AssignPackage', function ($scope, $http,) {
- $scope.cyberpanelLoading = true;
- $scope.AddAssignment = function () {
- $scope.cyberpanelLoading = false;
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- var data = {
- package: $('#packageSelection').val(),
- user: $scope.userSelection,
- };
-
-
- dataurl = "/websites/AddAssignment";
-
- $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
- function ListInitialDatas(response) {
- $scope.cyberpanelLoading = true;
- if (response.data.status === 1) {
- new PNotify({
- title: 'Success',
- text: 'Successfully saved.',
- 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'
- });
-
-
- }
- }
-
- var FinalDeletepackageURL;
- $scope.Deleteassingment = function (url) {
- FinalDeletepackageURL = url;
- // console.log(FinalDeletepackageURL);
- }
-
- $scope.ConfirmDelete = function () {
- window.location.href = FinalDeletepackageURL
- }
-
-})
-app.controller('createDockerSite', function ($scope, $http, $timeout) {
- $scope.cyberpanelLoading = true;
+app.controller('installWordPressCTRL', function ($scope, $http, $timeout) {
$scope.installationDetailsForm = false;
$scope.installationProgress = true;
- $scope.errorMessageBox = true;
- $scope.success = true;
+ $scope.installationFailed = true;
+ $scope.installationSuccessfull = true;
$scope.couldNotConnect = true;
+ $scope.wpInstallLoading = true;
$scope.goBackDisable = true;
var statusFile;
+ var domain = $("#domainNamePage").text();
+ var path;
- $scope.createdockersite = function () {
-
- $scope.cyberpanelLoading = false;
- $scope.installationDetailsForm = true;
- $scope.installationProgress = false;
- $scope.errorMessageBox = true;
- $scope.success = true;
- $scope.couldNotConnect = true;
- $scope.goBackDisable = true;
-
- $scope.currentStatus = "Starting creation..";
-
-
- url = "/websites/submitDockerSiteCreation";
-
- var package = $scope.packageForWebsite;
-
-
- var data = {
- sitename: $scope.siteName,
- Owner: $scope.userSelection,
- Domain: $scope.domainNameCreate,
- MysqlCPU: $scope.CPUMysql,
- MYsqlRam: $scope.rammysql,
- SiteCPU: $scope.CPUSite,
- SiteRam: $scope.RamSite,
- App: $scope.App,
- WPusername: $scope.WPUsername,
- WPemal: $scope.wpEmail,
- WPpasswd: $scope.WPpassword
- };
-
-
- var config = {
- headers: {
- 'X-CSRFToken': getCookie('csrftoken')
- }
- };
-
- $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
-
-
- function ListInitialDatas(response) {
- console.log('.........................')
- if (response.data.installStatus === 1) {
- console.log(response.data.installsatus)
- statusFile = response.data.tempStatusPath;
- getCreationStatus();
- } else {
-
- $scope.cyberpanelLoading = 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.cyberpanelLoading = true;
- $scope.installationDetailsForm = true;
- $scope.installationProgress = false;
- $scope.errorMessageBox = true;
- $scope.success = true;
- $scope.couldNotConnect = false;
- $scope.goBackDisable = false;
-
- }
-
-
- };
$scope.goBack = function () {
- $scope.cyberpanelLoading = true;
$scope.installationDetailsForm = false;
$scope.installationProgress = true;
- $scope.errorMessageBox = true;
- $scope.success = true;
+ $scope.installationFailed = true;
+ $scope.installationSuccessfull = 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.cyberpanelLoading = true;
- $scope.installationDetailsForm = true;
- $scope.installationProgress = false;
- $scope.errorMessageBox = true;
- $scope.success = false;
- $scope.couldNotConnect = true;
- $scope.goBackDisable = false;
+ $scope.wpInstallLoading = true;
+ $scope.goBackDisable = false;
$("#installProgress").css("width", "100%");
$scope.installPercentage = "100";
diff --git a/websiteFunctions/templates/websiteFunctions/listWebsites.html b/websiteFunctions/templates/websiteFunctions/listWebsites.html
index 4d85fdbae..0238e3a86 100755
--- a/websiteFunctions/templates/websiteFunctions/listWebsites.html
+++ b/websiteFunctions/templates/websiteFunctions/listWebsites.html
@@ -101,7 +101,7 @@
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Plugins
-
{$ wp.activePlugins || '0' $} active
-
-
-
-
-
-
-
-
-
- Password protection
-
-
-
-
Maintenance mode
+
+
+
+
+
+
+
WordPress Version: {{site.version}}
+
PHP Version: {{site.phpVersion}}
+
Active Theme: {{site.theme}}
+
Active Plugins: {{site.activePlugins}}
+
+
+
+
diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py
index 9469ca672..285f16931 100755
--- a/websiteFunctions/urls.py
+++ b/websiteFunctions/urls.py
@@ -194,4 +194,6 @@ 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 bcefc8a77..70e6b3dc4 100755
--- a/websiteFunctions/views.py
+++ b/websiteFunctions/views.py
@@ -1841,4 +1841,21 @@ def Dockersitehome(request, dockerapp):
wm = WebsiteManager(dockerapp)
return wm.Dockersitehome(request, userID, None)
except KeyError:
- return redirect(loadLoginPage)
\ No newline at end of file
+ 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
diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py
index e2e6c08e6..8cb377f18 100755
--- a/websiteFunctions/website.py
+++ b/websiteFunctions/website.py
@@ -1936,6 +1936,2025 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+ def UpdateWPSettings(self, userID=None, data=None):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ siteId = data['siteId']
+ setting = data['setting']
+ value = data['value']
+
+ wpsite = WPSites.objects.get(pk=siteId)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) != 1:
+ return ACLManager.loadError()
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['siteId'] = siteId
+ extraArgs['setting'] = setting
+ extraArgs['value'] = value
+
+ background = ApplicationInstaller('UpdateWPSettings', extraArgs)
+ background.start()
+
+ data_ret = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def GetWPSitesByDomain(self, userID=None, data=None):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ domain = data['domain']
+
+ # Get the website object for the domain
+ website = Websites.objects.get(domain=domain)
+
+ if ACLManager.checkOwnership(domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ # Get all WP sites for this website
+ wp_sites = WPSites.objects.filter(owner=website)
+
+ sites_data = []
+
+ for wp in wp_sites:
+ # Get PHP version
+ php = ACLManager.getPHPString(website.phpSelection)
+ FinalPHPPath = f'/usr/local/lsws/lsphp{php}/bin/php'
+
+ # Get WP version
+ command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path={wp.path} 2>/dev/null'
+ version = ProcessUtilities.outputExecutioner(command, None, True)
+ version = version.rstrip("\n") if version else 'Unknown'
+
+ # Get active plugins count
+ command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp plugin list --skip-plugins --skip-themes --format=json --path={wp.path}'
+ plugins_output = ProcessUtilities.outputExecutioner(command)
+ try:
+ plugins = json.loads(plugins_output.splitlines()[-1])
+ active_plugins = len([p for p in plugins if p['status'] == 'active'])
+ except:
+ active_plugins = 0
+
+ # Get active theme
+ command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp theme list --skip-plugins --skip-themes --format=json --path={wp.path}'
+ themes_output = ProcessUtilities.outputExecutioner(command)
+ try:
+ themes = json.loads(themes_output.splitlines()[-1])
+ active_theme = next((t['name'] for t in themes if t['status'] == 'active'), 'Unknown')
+ except:
+ active_theme = 'Unknown'
+
+ # Get other WP settings
+ command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp config list --skip-plugins --skip-themes --path={wp.path}'
+ config_output = ProcessUtilities.outputExecutioner(command)
+ debugging = 1 if 'WP_DEBUG\ttrue\tconstant' in config_output else 0
+
+ command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp option get blog_public --skip-plugins --skip-themes --path={wp.path}'
+ search_index = int(ProcessUtilities.outputExecutioner(command).splitlines()[-1])
+
+ command = f'sudo -u {website.externalApp} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp maintenance-mode status --skip-plugins --skip-themes --path={wp.path}'
+ maintenance_output = ProcessUtilities.outputExecutioner(command)
+ maintenance_mode = 0 if 'not active' in maintenance_output.splitlines()[-1] else 1
+
+ # Check password protection
+ vhost_pass_dir = f'/home/{domain}'
+ path = f'{vhost_pass_dir}/{wp.id}'
+ password_protection = 1 if os.path.exists(path) else 0
+
+ sites_data.append({
+ 'id': wp.id,
+ 'title': wp.title,
+ 'url': wp.FinalURL,
+ 'version': version,
+ 'phpVersion': website.phpSelection,
+ 'theme': active_theme,
+ 'activePlugins': active_plugins,
+ 'debugging': debugging,
+ 'searchIndex': search_index,
+ 'maintenanceMode': maintenance_mode,
+ 'passwordProtection': password_protection
+ })
+
+ return HttpResponse(json.dumps({
+ 'status': 1,
+ 'error_message': None,
+ 'data': sites_data
+ }))
+
+ except Websites.DoesNotExist:
+ return HttpResponse(json.dumps({
+ 'status': 0,
+ 'error_message': f'Website with domain {domain} does not exist'
+ }))
+ except Exception as e:
+ return HttpResponse(json.dumps({
+ 'status': 0,
+ 'error_message': str(e)
+ }))
+
+
+class WebsiteManager:
+ apache = 1
+ ols = 2
+ lsws = 3
+
+ def __init__(self, domain=None, childDomain=None):
+ self.domain = domain
+ self.childDomain = childDomain
+
+ def createWebsite(self, request=None, userID=None, data=None):
+
+ url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
+ data = {
+ "name": "all",
+ "IP": ACLManager.GetServerIP()
+ }
+
+ import requests
+ response = requests.post(url, data=json.dumps(data))
+ Status = response.json()['status']
+
+ test_domain_status = 0
+
+ if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
+ test_domain_status = 1
+
+ currentACL = ACLManager.loadedACL(userID)
+ adminNames = ACLManager.loadAllUsers(userID)
+ packagesName = ACLManager.loadPackages(userID, currentACL)
+ phps = PHPManager.findPHPVersions()
+
+ rnpss = randomPassword.generate_pass(10)
+
+ Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps, 'Randam_String': rnpss.lower(),
+ 'test_domain_data': test_domain_status}
+ proc = httpProc(request, 'websiteFunctions/createWebsite.html',
+ Data, 'createWebsite')
+ return proc.render()
+
+ def WPCreate(self, request=None, userID=None, data=None):
+ url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
+ data = {
+ "name": "wp-manager",
+ "IP": ACLManager.GetServerIP()
+ }
+
+ import requests
+ response = requests.post(url, data=json.dumps(data))
+ Status = response.json()['status']
+
+
+ if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
+ currentACL = ACLManager.loadedACL(userID)
+ adminNames = ACLManager.loadAllUsers(userID)
+ packagesName = ACLManager.loadPackages(userID, currentACL)
+
+ if len(packagesName) == 0:
+ packagesName = ['Default']
+
+ FinalVersions = []
+ userobj = Administrator.objects.get(pk=userID)
+ counter = 0
+ try:
+ import requests
+ WPVersions = json.loads(requests.get('https://api.wordpress.org/core/version-check/1.7/').text)[
+ 'offers']
+
+ for versions in WPVersions:
+ if counter == 7:
+ break
+ if versions['current'] not in FinalVersions:
+ FinalVersions.append(versions['current'])
+ counter = counter + 1
+ except:
+ FinalVersions = ['5.6', '5.5.3', '5.5.2']
+
+ Plugins = wpplugins.objects.filter(owner=userobj)
+ rnpss = randomPassword.generate_pass(10)
+
+ ##
+
+ test_domain_status = 1
+
+ Data = {'packageList': packagesName, "owernList": adminNames, 'WPVersions': FinalVersions,
+ 'Plugins': Plugins, 'Randam_String': rnpss.lower(), 'test_domain_data': test_domain_status}
+ proc = httpProc(request, 'websiteFunctions/WPCreate.html',
+ Data, 'createDatabase')
+ return proc.render()
+ else:
+ from django.shortcuts import reverse
+ return redirect(reverse('pricing'))
+
+ def ListWPSites(self, request=None, userID=None, DeleteID=None):
+ import json
+ currentACL = ACLManager.loadedACL(userID)
+
+ admin = Administrator.objects.get(pk=userID)
+ data = {}
+ wp_sites = ACLManager.GetALLWPObjects(currentACL, userID)
+ data['wp'] = wp_sites
+
+ try:
+ if DeleteID != None:
+ WPDelete = WPSites.objects.get(pk=DeleteID)
+
+ if ACLManager.checkOwnership(WPDelete.owner.domain, admin, currentACL) == 1:
+ WPDelete.delete()
+ except BaseException as msg:
+ pass
+
+ sites = []
+ for site in data['wp']:
+ sites.append({
+ 'id': site.id,
+ 'title': site.title,
+ 'url': site.FinalURL,
+ 'production_status': True
+ })
+
+ context = {
+ "wpsite": json.dumps(sites),
+ "status": 1,
+ "total_sites": len(sites),
+ "debug_info": json.dumps({
+ "user_id": userID,
+ "is_admin": bool(currentACL.get('admin', 0)),
+ "wp_sites_count": wp_sites.count()
+ })
+ }
+
+ proc = httpProc(request, 'websiteFunctions/WPsitesList.html', context)
+ return proc.render()
+
+ def WPHome(self, request=None, userID=None, WPid=None, DeleteID=None):
+ Data = {}
+ currentACL = ACLManager.loadedACL(userID)
+ WPobj = WPSites.objects.get(pk=WPid)
+ admin = Administrator.objects.get(pk=userID)
+
+ if ACLManager.checkOwnership(WPobj.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ try:
+
+ url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
+ data = {
+ "name": "wp-manager",
+ "IP": ACLManager.GetServerIP()
+ }
+
+ import requests
+ response = requests.post(url, data=json.dumps(data))
+ Status = response.json()['status']
+
+ rnpss = randomPassword.generate_pass(10)
+
+ Data['Randam_String'] = rnpss.lower()
+
+ if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
+ Data['wpsite'] = WPobj
+ Data['test_domain_data'] = 1
+
+ try:
+ DeleteID = request.GET.get('DeleteID', None)
+
+ if DeleteID != None:
+ wstagingDelete = WPStaging.objects.get(pk=DeleteID, owner=WPobj)
+ wstagingDelete.delete()
+
+ except BaseException as msg:
+ da = str(msg)
+
+ proc = httpProc(request, 'websiteFunctions/WPsiteHome.html',
+ Data, 'createDatabase')
+ return proc.render()
+ else:
+ from django.shortcuts import reverse
+ return redirect(reverse('pricing'))
+ except:
+ proc = httpProc(request, 'websiteFunctions/WPsiteHome.html',
+ Data, 'createDatabase')
+ return proc.render()
+
+ def RestoreHome(self, request=None, userID=None, BackupID=None):
+ Data = {}
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ if ACLManager.CheckForPremFeature('wp-manager'):
+
+ Data['backupobj'] = WPSitesBackup.objects.get(pk=BackupID)
+
+ if ACLManager.CheckIPBackupObjectOwner(currentACL, Data['backupobj'], admin) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ config = json.loads(Data['backupobj'].config)
+ Data['FileName'] = config['name']
+ try:
+ Data['Backuptype'] = config['Backuptype']
+
+ if Data['Backuptype'] == 'DataBase Backup' or Data['Backuptype'] == 'Website Backup':
+ Data['WPsites'] = [WPSites.objects.get(pk=Data['backupobj'].WPSiteID)]
+ else:
+ Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
+
+ except:
+ Data['Backuptype'] = None
+ Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
+
+ proc = httpProc(request, 'websiteFunctions/WPRestoreHome.html',
+ Data, 'createDatabase')
+ return proc.render()
+ else:
+ from django.shortcuts import reverse
+ return redirect(reverse('pricing'))
+
+ def RemoteBackupConfig(self, request=None, userID=None, DeleteID=None):
+ Data = {}
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ try:
+ if DeleteID != None:
+ BackupconfigDelete = RemoteBackupConfig.objects.get(pk=DeleteID)
+ BackupconfigDelete.delete()
+ except:
+ pass
+
+ if ACLManager.CheckForPremFeature('wp-manager'):
+
+ Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
+ allcon = RemoteBackupConfig.objects.all()
+ Data['backupconfigs'] = []
+ for i in allcon:
+ configr = json.loads(i.config)
+ if i.configtype == "SFTP":
+ Data['backupconfigs'].append({
+ 'id': i.pk,
+ 'Type': i.configtype,
+ 'HostName': configr['Hostname'],
+ 'Path': configr['Path']
+ })
+ elif i.configtype == "S3":
+ Provider = configr['Provider']
+ if Provider == "Backblaze":
+ Data['backupconfigs'].append({
+ 'id': i.pk,
+ 'Type': i.configtype,
+ 'HostName': Provider,
+ 'Path': configr['S3keyname']
+ })
+ else:
+ Data['backupconfigs'].append({
+ 'id': i.pk,
+ 'Type': i.configtype,
+ 'HostName': Provider,
+ 'Path': configr['S3keyname']
+ })
+
+ proc = httpProc(request, 'websiteFunctions/RemoteBackupConfig.html',
+ Data, 'createDatabase')
+ return proc.render()
+ else:
+ from django.shortcuts import reverse
+ return redirect(reverse('pricing'))
+
+ def BackupfileConfig(self, request=None, userID=None, RemoteConfigID=None, DeleteID=None):
+ Data = {}
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ Data['RemoteConfigID'] = RemoteConfigID
+ RemoteConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
+ try:
+ if DeleteID != None:
+ RemoteBackupConfigDelete = RemoteBackupSchedule.objects.get(pk=DeleteID)
+ RemoteBackupConfigDelete.delete()
+ except:
+ pass
+
+ if ACLManager.CheckForPremFeature('wp-manager'):
+ Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
+ allsechedule = RemoteBackupSchedule.objects.filter(RemoteBackupConfig=RemoteConfigobj)
+ Data['Backupschedule'] = []
+ for i in allsechedule:
+ lastrun = i.lastrun
+ LastRun = time.strftime('%Y-%m-%d', time.localtime(float(lastrun)))
+ Data['Backupschedule'].append({
+ 'id': i.pk,
+ 'Name': i.Name,
+ 'RemoteConfiguration': i.RemoteBackupConfig.configtype,
+ 'Retention': i.fileretention,
+ 'Frequency': i.timeintervel,
+ 'LastRun': LastRun
+ })
+ proc = httpProc(request, 'websiteFunctions/BackupfileConfig.html',
+ Data, 'createDatabase')
+ return proc.render()
+ else:
+ from django.shortcuts import reverse
+ return redirect(reverse('pricing'))
+
+ def AddRemoteBackupsite(self, request=None, userID=None, RemoteScheduleID=None, DeleteSiteID=None):
+ Data = {}
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ Data['RemoteScheduleID'] = RemoteScheduleID
+ RemoteBackupScheduleobj = RemoteBackupSchedule.objects.get(pk=RemoteScheduleID)
+
+ try:
+ if DeleteSiteID != None:
+ RemoteBackupsitesDelete = RemoteBackupsites.objects.get(pk=DeleteSiteID)
+ RemoteBackupsitesDelete.delete()
+ except:
+ pass
+
+ if ACLManager.CheckForPremFeature('wp-manager'):
+ Data['WPsites'] = ACLManager.GetALLWPObjects(currentACL, userID)
+ allRemoteBackupsites = RemoteBackupsites.objects.filter(owner=RemoteBackupScheduleobj)
+ Data['RemoteBackupsites'] = []
+ for i in allRemoteBackupsites:
+ try:
+ wpsite = WPSites.objects.get(pk=i.WPsites)
+ Data['RemoteBackupsites'].append({
+ 'id': i.pk,
+ 'Title': wpsite.title,
+ })
+ except:
+ pass
+ proc = httpProc(request, 'websiteFunctions/AddRemoteBackupSite.html',
+ Data, 'createDatabase')
+ return proc.render()
+ else:
+ from django.shortcuts import reverse
+ return redirect(reverse('pricing'))
+
+ def WordpressPricing(self, request=None, userID=None, ):
+ Data = {}
+ proc = httpProc(request, 'websiteFunctions/CyberpanelPricing.html', Data, 'createWebsite')
+ return proc.render()
+
+ def RestoreBackups(self, request=None, userID=None, DeleteID=None):
+ Data = {}
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
+ data = {
+ "name": "wp-manager",
+ "IP": ACLManager.GetServerIP()
+ }
+
+ import requests
+ response = requests.post(url, data=json.dumps(data))
+ Status = response.json()['status']
+
+ if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
+
+ backobj = WPSitesBackup.objects.filter(owner=admin).order_by('-id')
+
+ # if ACLManager.CheckIPBackupObjectOwner(currentACL, backobj, admin) == 1:
+ # pass
+ # else:
+ # return ACLManager.loadError()
+
+ try:
+ if DeleteID != None:
+ DeleteIDobj = WPSitesBackup.objects.get(pk=DeleteID)
+
+ if ACLManager.CheckIPBackupObjectOwner(currentACL, DeleteIDobj, admin) == 1:
+ config = DeleteIDobj.config
+ conf = json.loads(config)
+ FileName = conf['name']
+ command = "rm -r /home/backup/%s.tar.gz" % FileName
+ ProcessUtilities.executioner(command)
+ DeleteIDobj.delete()
+
+ except BaseException as msg:
+ pass
+ Data['job'] = []
+
+ for sub in backobj:
+ try:
+ wpsite = WPSites.objects.get(pk=sub.WPSiteID)
+ web = wpsite.title
+ except:
+ web = "Website Not Found"
+
+ try:
+ config = sub.config
+ conf = json.loads(config)
+ Backuptype = conf['Backuptype']
+ BackupDestination = conf['BackupDestination']
+ except:
+ Backuptype = "Backup type not exists"
+
+ Data['job'].append({
+ 'id': sub.id,
+ 'title': web,
+ 'Backuptype': Backuptype,
+ 'BackupDestination': BackupDestination
+ })
+
+ proc = httpProc(request, 'websiteFunctions/RestoreBackups.html',
+ Data, 'createDatabase')
+ return proc.render()
+ else:
+ from django.shortcuts import reverse
+ return redirect(reverse('pricing'))
+
+ def AutoLogin(self, request=None, userID=None):
+
+ WPid = request.GET.get('id')
+ currentACL = ACLManager.loadedACL(userID)
+ WPobj = WPSites.objects.get(pk=WPid)
+ admin = Administrator.objects.get(pk=userID)
+
+ if ACLManager.checkOwnership(WPobj.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ from managePHP.phpManager import PHPManager
+
+ php = PHPManager.getPHPString(WPobj.owner.phpSelection)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
+ data = {
+ "name": "wp-manager",
+ "IP": ACLManager.GetServerIP()
+ }
+
+ import requests
+ response = requests.post(url, data=json.dumps(data))
+ Status = response.json()['status']
+
+ if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
+
+ ## Get title
+
+ password = randomPassword.generate_pass(10)
+
+ command = f'sudo -u %s {FinalPHPPath} /usr/bin/wp user create autologin %s --role=administrator --user_pass="%s" --path=%s --skip-plugins --skip-themes' % (
+ WPobj.owner.externalApp, 'autologin@cloudpages.cloud', password, WPobj.path)
+ ProcessUtilities.executioner(command)
+
+ command = f'sudo -u %s {FinalPHPPath} /usr/bin/wp user update autologin --user_pass="%s" --path=%s --skip-plugins --skip-themes' % (
+ WPobj.owner.externalApp, password, WPobj.path)
+ ProcessUtilities.executioner(command)
+
+ data = {}
+
+ if WPobj.FinalURL.endswith('/'):
+ FinalURL = WPobj.FinalURL[:-1]
+ else:
+ FinalURL = WPobj.FinalURL
+
+ data['url'] = 'https://%s' % (FinalURL)
+ data['userName'] = 'autologin'
+ data['password'] = password
+
+ proc = httpProc(request, 'websiteFunctions/AutoLogin.html',
+ data, 'createDatabase')
+ return proc.render()
+ else:
+ from django.shortcuts import reverse
+ return redirect(reverse('pricing'))
+
+ def ConfigurePlugins(self, request=None, userID=None, data=None):
+
+ if ACLManager.CheckForPremFeature('wp-manager'):
+ currentACL = ACLManager.loadedACL(userID)
+ userobj = Administrator.objects.get(pk=userID)
+
+ Selectedplugins = wpplugins.objects.filter(owner=userobj)
+ # data['Selectedplugins'] = wpplugins.objects.filter(ProjectOwner=HostingCompany)
+
+ Data = {'Selectedplugins': Selectedplugins, }
+ proc = httpProc(request, 'websiteFunctions/WPConfigurePlugins.html',
+ Data, 'createDatabase')
+ return proc.render()
+ else:
+ from django.shortcuts import reverse
+ return redirect(reverse('pricing'))
+
+ def Addnewplugin(self, request=None, userID=None, data=None):
+ from django.shortcuts import reverse
+ if ACLManager.CheckForPremFeature('wp-manager'):
+ currentACL = ACLManager.loadedACL(userID)
+ adminNames = ACLManager.loadAllUsers(userID)
+ packagesName = ACLManager.loadPackages(userID, currentACL)
+ phps = PHPManager.findPHPVersions()
+
+ Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
+ proc = httpProc(request, 'websiteFunctions/WPAddNewPlugin.html',
+ Data, 'createDatabase')
+ return proc.render()
+
+ return redirect(reverse('pricing'))
+
+ def SearchOnkeyupPlugin(self, userID=None, data=None):
+ try:
+ if ACLManager.CheckForPremFeature('wp-manager'):
+ currentACL = ACLManager.loadedACL(userID)
+
+ pluginname = data['pluginname']
+ # logging.CyberCPLogFileWriter.writeToFile("Plugin Name ....... %s"%pluginname)
+
+ url = "http://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[search]=%s" % str(
+ pluginname)
+ import requests
+
+ res = requests.get(url)
+ r = res.json()
+
+ # return proc.ajax(1, 'Done', {'plugins': r})
+
+ data_ret = {'status': 1, 'plugns': r, }
+
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+ else:
+ data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': 'Premium feature not available.'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def AddNewpluginAjax(self, userID=None, data=None):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+
+ userobj = Administrator.objects.get(pk=userID)
+
+ config = data['config']
+ Name = data['Name']
+ # pluginname = data['pluginname']
+ # logging.CyberCPLogFileWriter.writeToFile("config ....... %s"%config)
+ # logging.CyberCPLogFileWriter.writeToFile(" Name ....... %s"%Name)
+
+ addpl = wpplugins(Name=Name, config=json.dumps(config), owner=userobj)
+ addpl.save()
+
+ data_ret = {'status': 1}
+
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'AddNewpluginAjax': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def EidtPlugin(self, request=None, userID=None, pluginbID=None):
+ Data = {}
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ pluginobj = wpplugins.objects.get(pk=pluginbID)
+
+ if ACLManager.CheckIPPluginObjectOwner(currentACL, pluginobj, admin) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ lmo = json.loads(pluginobj.config)
+ Data['Selectedplugins'] = lmo
+ Data['pluginbID'] = pluginbID
+ Data['BucketName'] = pluginobj.Name
+
+ proc = httpProc(request, 'websiteFunctions/WPEidtPlugin.html',
+ Data, 'createDatabase')
+ return proc.render()
+
+ def deletesPlgin(self, userID=None, data=None, ):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ userobj = Administrator.objects.get(pk=userID)
+ pluginname = data['pluginname']
+ pluginbBucketID = data['pluginbBucketID']
+ # logging.CyberCPLogFileWriter.writeToFile("pluginbID ....... %s" % pluginbBucketID)
+ # logging.CyberCPLogFileWriter.writeToFile("pluginname ....... %s" % pluginname)
+
+ obj = wpplugins.objects.get(pk=pluginbBucketID, owner=userobj)
+
+ if ACLManager.CheckIPPluginObjectOwner(currentACL, obj, admin) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ ab = []
+ ab = json.loads(obj.config)
+ ab.remove(pluginname)
+ obj.config = json.dumps(ab)
+ obj.save()
+
+ data_ret = {'status': 1}
+
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+ except BaseException as msg:
+ data_ret = {'status': 0, 'deletesPlgin': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def Addplugineidt(self, userID=None, data=None, ):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ userobj = Administrator.objects.get(pk=userID)
+ pluginname = data['pluginname']
+ pluginbBucketID = data['pluginbBucketID']
+
+ # logging.CyberCPLogFileWriter.writeToFile("pluginbID ....... %s" % pluginbBucketID)
+ # logging.CyberCPLogFileWriter.writeToFile("pluginname ....... %s" % pluginname)
+
+ pObj = wpplugins.objects.get(pk=pluginbBucketID, owner=userobj)
+
+ if ACLManager.CheckIPPluginObjectOwner(currentACL, pObj, admin) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ listofplugin = json.loads(pObj.config)
+ try:
+ index = listofplugin.index(pluginname)
+ print('index.....%s' % index)
+ if (index >= 0):
+ data_ret = {'status': 0, 'deletesPlgin': 0, 'error_message': str('Already Save in your Plugin lis')}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except:
+ ab = []
+ ab = json.loads(pObj.config)
+ ab.append(pluginname)
+ pObj.config = json.dumps(ab)
+ pObj.save()
+
+ data_ret = {'status': 1}
+
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+ except BaseException as msg:
+ data_ret = {'status': 0, 'deletesPlgin': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def modifyWebsite(self, request=None, userID=None, data=None):
+ currentACL = ACLManager.loadedACL(userID)
+
+ websitesName = ACLManager.findAllSites(currentACL, userID)
+ phps = PHPManager.findPHPVersions()
+ proc = httpProc(request, 'websiteFunctions/modifyWebsite.html',
+ {'websiteList': websitesName, 'phps': phps}, 'modifyWebsite')
+ return proc.render()
+
+ def deleteWebsite(self, request=None, userID=None, data=None):
+ currentACL = ACLManager.loadedACL(userID)
+ websitesName = ACLManager.findAllSites(currentACL, userID)
+ proc = httpProc(request, 'websiteFunctions/deleteWebsite.html',
+ {'websiteList': websitesName}, 'deleteWebsite')
+ return proc.render()
+
+ def CreateNewDomain(self, request=None, userID=None, data=None):
+ currentACL = ACLManager.loadedACL(userID)
+ websitesName = ACLManager.findAllSites(currentACL, userID)
+
+ try:
+ admin = Administrator.objects.get(pk=userID)
+ if admin.defaultSite == 0:
+ websites = ACLManager.findWebsiteObjects(currentACL, userID)
+ admin.defaultSite = websites[0].id
+ admin.save()
+ except:
+ pass
+
+ try:
+ admin = Administrator.objects.get(pk=userID)
+ defaultDomain = Websites.objects.get(pk=admin.defaultSite).domain
+ except:
+ try:
+ admin = Administrator.objects.get(pk=userID)
+ websites = ACLManager.findWebsiteObjects(currentACL, userID)
+ admin.defaultSite = websites[0].id
+ admin.save()
+ defaultDomain = websites[0].domain
+ except:
+ defaultDomain='NONE'
+
+
+ url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
+ data = {
+ "name": "all",
+ "IP": ACLManager.GetServerIP()
+ }
+
+ import requests
+ response = requests.post(url, data=json.dumps(data))
+ Status = response.json()['status']
+
+ test_domain_status = 0
+
+ if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
+ test_domain_status = 1
+
+ rnpss = randomPassword.generate_pass(10)
+ proc = httpProc(request, 'websiteFunctions/createDomain.html',
+ {'websiteList': websitesName, 'phps': PHPManager.findPHPVersions(), 'Randam_String': rnpss,
+ 'test_domain_data': test_domain_status, 'defaultSite': defaultDomain})
+ return proc.render()
+
+ def siteState(self, request=None, userID=None, data=None):
+ currentACL = ACLManager.loadedACL(userID)
+
+ websitesName = ACLManager.findAllSites(currentACL, userID)
+
+ proc = httpProc(request, 'websiteFunctions/suspendWebsite.html',
+ {'websiteList': websitesName}, 'suspendWebsite')
+ return proc.render()
+
+ def listWebsites(self, request=None, userID=None, data=None):
+ currentACL = ACLManager.loadedACL(userID)
+ pagination = self.websitePagination(currentACL, userID)
+ proc = httpProc(request, 'websiteFunctions/listWebsites.html',
+ {"pagination": pagination})
+ return proc.render()
+
+ def listChildDomains(self, request=None, userID=None, data=None):
+ currentACL = ACLManager.loadedACL(userID)
+ adminNames = ACLManager.loadAllUsers(userID)
+ packagesName = ACLManager.loadPackages(userID, currentACL)
+ phps = PHPManager.findPHPVersions()
+
+ Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
+ proc = httpProc(request, 'websiteFunctions/listChildDomains.html',
+ Data)
+ return proc.render()
+
+ def listCron(self, request=None, userID=None, data=None):
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ if ACLManager.checkOwnership(request.GET.get('domain'), admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ proc = httpProc(request, 'websiteFunctions/listCron.html',
+ {'domain': request.GET.get('domain')})
+ return proc.render()
+
+ def domainAlias(self, request=None, userID=None, data=None):
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ aliasManager = AliasManager(self.domain)
+ noAlias, finalAlisList = aliasManager.fetchAlisForDomains()
+
+ path = "/home/" + self.domain + "/public_html"
+
+ proc = httpProc(request, 'websiteFunctions/domainAlias.html', {
+ 'masterDomain': self.domain,
+ 'aliases': finalAlisList,
+ 'path': path,
+ 'noAlias': noAlias
+ })
+ return proc.render()
+
+ def FetchWPdata(self, userID=None, data=None):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s 2>/dev/null' % (
+ Vhuser, FinalPHPPath, path)
+ version = ProcessUtilities.outputExecutioner(command, None, True)
+ version = html.escape(version)
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin status litespeed-cache --skip-plugins --skip-themes --path=%s' % (
+ Vhuser, FinalPHPPath, path)
+ lscachee = ProcessUtilities.outputExecutioner(command)
+
+ if lscachee.find('Status: Active') > -1:
+ lscache = 1
+ else:
+ lscache = 0
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config list --skip-plugins --skip-themes --path=%s' % (
+ Vhuser, FinalPHPPath, path)
+ stdout = ProcessUtilities.outputExecutioner(command)
+ debugging = 0
+ for items in stdout.split('\n'):
+ if items.find('WP_DEBUG true constant') > -1:
+ debugging = 1
+ break
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp option get blog_public --skip-plugins --skip-themes --path=%s' % (
+ Vhuser, FinalPHPPath, path)
+ stdoutput = ProcessUtilities.outputExecutioner(command)
+ searchindex = int(stdoutput.splitlines()[-1])
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp maintenance-mode status --skip-plugins --skip-themes --path=%s' % (
+ Vhuser, FinalPHPPath, path)
+ maintenanceMod = ProcessUtilities.outputExecutioner(command)
+
+ result = maintenanceMod.splitlines()[-1]
+ if result.find('not active') > -1:
+ maintenanceMode = 0
+ else:
+ maintenanceMode = 1
+
+ ##### Check passwd protection
+ vhostName = wpsite.owner.domain
+ vhostPassDir = f'/home/{vhostName}'
+ path = f'{vhostPassDir}/{WPManagerID}'
+ if os.path.exists(path):
+ passwd = 1
+ else:
+ passwd = 0
+
+ #### Check WP cron
+ command = "sudo -u %s cat %s/wp-config.php" % (Vhuser, wpsite.path)
+ stdout = ProcessUtilities.outputExecutioner(command)
+ if stdout.find("'DISABLE_WP_CRON', 'true'") > -1:
+ wpcron = 1
+ else:
+ wpcron = 0
+
+ fb = {
+ 'version': version.rstrip('\n'),
+ 'lscache': lscache,
+ 'debugging': debugging,
+ 'searchIndex': searchindex,
+ 'maintenanceMode': maintenanceMode,
+ 'passwordprotection': passwd,
+ 'wpcron': wpcron
+
+ }
+
+ data_ret = {'status': 1, 'error_message': 'None', 'ret_data': fb}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def GetCurrentPlugins(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin list --skip-plugins --skip-themes --format=json --path=%s' % (
+ Vhuser, FinalPHPPath, path)
+ stdoutput = ProcessUtilities.outputExecutioner(command)
+ json_data = stdoutput.splitlines()[-1]
+
+ data_ret = {'status': 1, 'error_message': 'None', 'plugins': json_data}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def GetCurrentThemes(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp theme list --skip-plugins --skip-themes --format=json --path=%s' % (
+ Vhuser, FinalPHPPath, path)
+ stdoutput = ProcessUtilities.outputExecutioner(command)
+ json_data = stdoutput.splitlines()[-1]
+
+ data_ret = {'status': 1, 'error_message': 'None', 'themes': json_data}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def fetchstaging(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ from plogical.phpUtilities import phpUtilities
+
+ json_data = phpUtilities.GetStagingInJson(wpsite.wpstaging_set.all().order_by('-id'))
+
+ data_ret = {'status': 1, 'error_message': 'None', 'wpsites': json_data}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def fetchDatabase(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ php = PHPManager.getPHPString(wpsite.owner.phpSelection)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ command = f'{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path={wpsite.path} 2>/dev/null'
+ retStatus, stdoutput = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp, True, None, 1)
+
+ if stdoutput.find('Error:') == -1:
+ DataBaseName = stdoutput.rstrip("\n")
+ DataBaseName = html.escape(DataBaseName)
+ else:
+ data_ret = {'status': 0, 'error_message': stdoutput}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ command = f'{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config get DB_USER --skip-plugins --skip-themes --path={wpsite.path} 2>/dev/null'
+ retStatus, stdoutput = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp, True, None, 1)
+
+ if stdoutput.find('Error:') == -1:
+ DataBaseUser = stdoutput.rstrip("\n")
+ DataBaseUser = html.escape(DataBaseUser)
+ else:
+ data_ret = {'status': 0, 'error_message': stdoutput}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ command = f'{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config get table_prefix --skip-plugins --skip-themes --path={wpsite.path} 2>/dev/null'
+ retStatus, stdoutput = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp, True, None, 1)
+
+ if stdoutput.find('Error:') == -1:
+ tableprefix = stdoutput.rstrip("\n")
+ tableprefix = html.escape(tableprefix)
+ else:
+ data_ret = {'status': 0, 'error_message': stdoutput}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ data_ret = {'status': 1, 'error_message': 'None', "DataBaseUser": DataBaseUser,
+ "DataBaseName": DataBaseName, 'tableprefix': tableprefix}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def SaveUpdateConfig(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ Plugins = data['Plugins']
+ Themes = data['Themes']
+ AutomaticUpdates = data['AutomaticUpdates']
+
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+
+ php = PHPManager.getPHPString(wpsite.owner.phpSelection)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ if AutomaticUpdates == 'Disabled':
+ command = f"{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config set WP_AUTO_UPDATE_CORE false --raw --allow-root --path=" + wpsite.path
+ result = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp)
+
+ if result.find('Success:') == -1:
+ raise BaseException(result)
+ elif AutomaticUpdates == 'Minor and Security Updates':
+ command = f"{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config set WP_AUTO_UPDATE_CORE minor --allow-root --path=" + wpsite.path
+ result = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp)
+
+ if result.find('Success:') == -1:
+ raise BaseException(result)
+ else:
+ command = f"{FinalPHPPath} -d error_reporting=0 /usr/bin/wp config set WP_AUTO_UPDATE_CORE true --raw --allow-root --path=" + wpsite.path
+ result = ProcessUtilities.outputExecutioner(command, wpsite.owner.externalApp)
+
+ if result.find('Success:') == -1:
+ raise BaseException(result)
+
+ wpsite.AutoUpdates = AutomaticUpdates
+ wpsite.PluginUpdates = Plugins
+ wpsite.ThemeUpdates = Themes
+ wpsite.save()
+
+ data_ret = {'status': 1, 'error_message': 'None', }
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def DeploytoProduction(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ statgingID = data['StagingID']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+ StagingObj = WPSites.objects.get(pk=statgingID)
+
+ ###
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ if ACLManager.checkOwnership(StagingObj.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ ###
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['statgingID'] = statgingID
+ extraArgs['WPid'] = WPManagerID
+ extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
+
+ background = ApplicationInstaller('DeploytoProduction', extraArgs)
+ background.start()
+
+ time.sleep(2)
+
+ data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
+ 'tempStatusPath': extraArgs['tempStatusPath']}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def WPCreateBackup(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ Backuptype = data['Backuptype']
+
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['WPid'] = WPManagerID
+ extraArgs['Backuptype'] = Backuptype
+ extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
+
+ background = ApplicationInstaller('WPCreateBackup', extraArgs)
+ background.start()
+
+ time.sleep(2)
+
+ data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
+ 'tempStatusPath': extraArgs['tempStatusPath']}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def RestoreWPbackupNow(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ backupid = data['backupid']
+ DesSiteID = data['DesSite']
+
+ # try:
+ #
+ # bwp = WPSites.objects.get(pk=int(backupid))
+ #
+ # if ACLManager.checkOwnership(bwp.owner.domain, admin, currentACL) == 1:
+ # pass
+ # else:
+ # return ACLManager.loadError()
+ #
+ # except:
+ # pass
+ #
+ # dwp = WPSites.objects.get(pk=int(DesSiteID))
+ # if ACLManager.checkOwnership(dwp.owner.domain, admin, currentACL) == 1:
+ # pass
+ # else:
+ # return ACLManager.loadError()
+
+ Domain = data['Domain']
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['backupid'] = backupid
+ extraArgs['DesSiteID'] = DesSiteID
+ extraArgs['Domain'] = Domain
+ extraArgs['path'] = data['path']
+ extraArgs['home'] = data['home']
+ extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
+
+ background = ApplicationInstaller('RestoreWPbackupNow', extraArgs)
+ background.start()
+
+ time.sleep(2)
+
+ data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
+ 'tempStatusPath': extraArgs['tempStatusPath']}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def SaveBackupConfig(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ ConfigType = data['type']
+ if ConfigType == 'SFTP':
+ Hname = data['Hname']
+ Uname = data['Uname']
+ Passwd = data['Passwd']
+ path = data['path']
+ config = {
+ "Hostname": Hname,
+ "Username": Uname,
+ "Password": Passwd,
+ "Path": path
+ }
+ elif ConfigType == "S3":
+ Provider = data['Provider']
+ if Provider == "Backblaze":
+ S3keyname = data['S3keyname']
+ SecertKey = data['SecertKey']
+ AccessKey = data['AccessKey']
+ EndUrl = data['EndUrl']
+ config = {
+ "Provider": Provider,
+ "S3keyname": S3keyname,
+ "SecertKey": SecertKey,
+ "AccessKey": AccessKey,
+ "EndUrl": EndUrl
+
+ }
+ else:
+ S3keyname = data['S3keyname']
+ SecertKey = data['SecertKey']
+ AccessKey = data['AccessKey']
+ config = {
+ "Provider": Provider,
+ "S3keyname": S3keyname,
+ "SecertKey": SecertKey,
+ "AccessKey": AccessKey,
+
+ }
+
+ mkobj = RemoteBackupConfig(owner=admin, configtype=ConfigType, config=json.dumps(config))
+ mkobj.save()
+
+ time.sleep(1)
+
+ data_ret = {'status': 1, 'error_message': 'None', }
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def SaveBackupSchedule(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ FileRetention = data['FileRetention']
+ Backfrequency = data['Backfrequency']
+ ScheduleName = data['ScheduleName']
+ RemoteConfigID = data['RemoteConfigID']
+ BackupType = data['BackupType']
+
+ RemoteBackupConfigobj = RemoteBackupConfig.objects.get(pk=RemoteConfigID)
+ Rconfig = json.loads(RemoteBackupConfigobj.config)
+
+ try:
+ # This code is only supposed to run if backups are s3, not for SFTP
+ provider = Rconfig['Provider']
+ if provider == "Backblaze":
+ EndURl = Rconfig['EndUrl']
+ elif provider == "Amazon":
+ EndURl = "https://s3.us-east-1.amazonaws.com"
+ elif provider == "Wasabi":
+ EndURl = "https://s3.wasabisys.com"
+
+ AccessKey = Rconfig['AccessKey']
+ SecertKey = Rconfig['SecertKey']
+
+ session = boto3.session.Session()
+
+ client = session.client(
+ 's3',
+ endpoint_url=EndURl,
+ aws_access_key_id=AccessKey,
+ aws_secret_access_key=SecertKey,
+ verify=False
+ )
+
+ ############Creating Bucket
+ BucketName = randomPassword.generate_pass().lower()
+
+ try:
+ client.create_bucket(Bucket=BucketName)
+ except BaseException as msg:
+ logging.CyberCPLogFileWriter.writeToFile("Creating Bucket Error: %s" % str(msg))
+ data_ret = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ config = {
+ 'BackupType': BackupType,
+ 'BucketName': BucketName
+ }
+ except BaseException as msg:
+ config = {'BackupType': BackupType}
+ pass
+
+ svobj = RemoteBackupSchedule(RemoteBackupConfig=RemoteBackupConfigobj, Name=ScheduleName,
+ timeintervel=Backfrequency, fileretention=FileRetention,
+ config=json.dumps(config),
+ lastrun=str(time.time()))
+ svobj.save()
+
+ data_ret = {'status': 1, 'error_message': 'None', }
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def AddWPsiteforRemoteBackup(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ WPid = data['WpsiteID']
+ RemoteScheduleID = data['RemoteScheduleID']
+
+ wpsiteobj = WPSites.objects.get(pk=WPid)
+ WPpath = wpsiteobj.path
+ VHuser = wpsiteobj.owner.externalApp
+ PhpVersion = wpsiteobj.owner.phpSelection
+ php = PHPManager.getPHPString(PhpVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ ####Get DB Name
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config get DB_NAME --skip-plugins --skip-themes --path=%s' % (
+ VHuser, FinalPHPPath, WPpath)
+ result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
+
+ if stdout.find('Error:') > -1:
+ raise BaseException(stdout)
+ else:
+ Finaldbname = stdout.rstrip("\n")
+
+ ## Get DB obj
+ try:
+ DBobj = Databases.objects.get(dbName=Finaldbname)
+ except:
+ raise BaseException(str("DataBase Not Found"))
+ RemoteScheduleIDobj = RemoteBackupSchedule.objects.get(pk=RemoteScheduleID)
+
+ svobj = RemoteBackupsites(owner=RemoteScheduleIDobj, WPsites=WPid, database=DBobj.pk)
+ svobj.save()
+
+ data_ret = {'status': 1, 'error_message': 'None', }
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def UpdateRemoteschedules(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ ScheduleID = data['ScheduleID']
+ Frequency = data['Frequency']
+ FileRetention = data['FileRetention']
+
+ scheduleobj = RemoteBackupSchedule.objects.get(pk=ScheduleID)
+ scheduleobj.timeintervel = Frequency
+ scheduleobj.fileretention = FileRetention
+ scheduleobj.save()
+
+ data_ret = {'status': 1, 'error_message': 'None', }
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def ScanWordpressSite(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ allweb = Websites.objects.all()
+
+ childdomain = ChildDomains.objects.all()
+
+ for web in allweb:
+ webpath = "/home/%s/public_html/" % web.domain
+ command = "cat %swp-config.php" % webpath
+ result = ProcessUtilities.outputExecutioner(command, web.externalApp)
+
+ if os.path.exists(ProcessUtilities.debugPath):
+ logging.CyberCPLogFileWriter.writeToFile(result)
+
+ if result.find('No such file or directory') == -1:
+ try:
+ WPSites.objects.get(path=webpath)
+ except:
+ wpobj = WPSites(owner=web, title=web.domain, path=webpath, FinalURL=web.domain,
+ AutoUpdates="Enabled", PluginUpdates="Enabled",
+ ThemeUpdates="Enabled", )
+ wpobj.save()
+
+ for chlid in childdomain:
+ childPath = chlid.path.rstrip('/')
+
+ command = "cat %s/wp-config.php" % childPath
+ result = ProcessUtilities.outputExecutioner(command, chlid.master.externalApp)
+
+ if os.path.exists(ProcessUtilities.debugPath):
+ logging.CyberCPLogFileWriter.writeToFile(result)
+
+ if result.find('No such file or directory') == -1:
+ fChildPath = f'{childPath}/'
+ try:
+ WPSites.objects.get(path=fChildPath)
+ except:
+
+ wpobj = WPSites(owner=chlid.master, title=chlid.domain, path=fChildPath, FinalURL=chlid.domain,
+ AutoUpdates="Enabled", PluginUpdates="Enabled",
+ ThemeUpdates="Enabled", )
+ wpobj.save()
+
+ data_ret = {'status': 1, 'error_message': 'None', }
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def installwpcore(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ ###fetch WP version
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s 2>/dev/null' % (
+ Vhuser, FinalPHPPath, path)
+ version = ProcessUtilities.outputExecutioner(command, None, True)
+ version = version.rstrip("\n")
+
+ ###install wp core
+ command = f"sudo -u {Vhuser} {FinalPHPPath} -d error_reporting=0 /usr/bin/wp core download --force --skip-content --version={version} --path={path}"
+ output = ProcessUtilities.outputExecutioner(command)
+
+ data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None', 'result': output}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def dataintegrity(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ ###fetch WP version
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core verify-checksums --skip-plugins --skip-themes --path=%s' % (
+ Vhuser, FinalPHPPath, path)
+ result = ProcessUtilities.outputExecutioner(command)
+
+ data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None', 'result': result}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def UpdatePlugins(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ plugin = data['plugin']
+ pluginarray = data['pluginarray']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['plugin'] = plugin
+ extraArgs['pluginarray'] = pluginarray
+ extraArgs['FinalPHPPath'] = FinalPHPPath
+ extraArgs['path'] = path
+ extraArgs['Vhuser'] = Vhuser
+
+ background = ApplicationInstaller('UpdateWPPlugin', extraArgs)
+ background.start()
+
+ time.sleep(2)
+
+ data_ret = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def UpdateThemes(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ Theme = data['Theme']
+ Themearray = data['Themearray']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['Theme'] = Theme
+ extraArgs['Themearray'] = Themearray
+ extraArgs['FinalPHPPath'] = FinalPHPPath
+ extraArgs['path'] = path
+ extraArgs['Vhuser'] = Vhuser
+
+ background = ApplicationInstaller('UpdateWPTheme', extraArgs)
+ background.start()
+
+ time.sleep(2)
+
+ data_ret = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def DeletePlugins(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ plugin = data['plugin']
+ pluginarray = data['pluginarray']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['plugin'] = plugin
+ extraArgs['pluginarray'] = pluginarray
+ extraArgs['FinalPHPPath'] = FinalPHPPath
+ extraArgs['path'] = path
+ extraArgs['Vhuser'] = Vhuser
+
+ background = ApplicationInstaller('DeletePlugins', extraArgs)
+ background.start()
+
+ time.sleep(2)
+
+ data_ret = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def DeleteThemes(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ Theme = data['Theme']
+ Themearray = data['Themearray']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['Theme'] = Theme
+ extraArgs['Themearray'] = Themearray
+ extraArgs['FinalPHPPath'] = FinalPHPPath
+ extraArgs['path'] = path
+ extraArgs['Vhuser'] = Vhuser
+
+ background = ApplicationInstaller('DeleteThemes', extraArgs)
+ background.start()
+
+ data_ret = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def ChangeStatus(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ plugin = data['plugin']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin status %s --skip-plugins --skip-themes --path=%s' % (
+ Vhuser, FinalPHPPath, plugin, path)
+ stdoutput = ProcessUtilities.outputExecutioner(command)
+
+ if stdoutput.find('Status: Active') > -1:
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin deactivate %s --skip-plugins --skip-themes --path=%s' % (
+ Vhuser, FinalPHPPath, plugin, path)
+ stdoutput = ProcessUtilities.outputExecutioner(command)
+ time.sleep(3)
+
+ else:
+
+ command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin activate %s --skip-plugins --skip-themes --path=%s' % (
+ Vhuser, FinalPHPPath, plugin, path)
+ stdoutput = ProcessUtilities.outputExecutioner(command)
+ time.sleep(3)
+
+ data_ret = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def ChangeStatusThemes(self, userID=None, data=None):
+ try:
+ # logging.CyberCPLogFileWriter.writeToFile("Error WP ChangeStatusThemes ....... %s")
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ WPManagerID = data['WPid']
+ Theme = data['theme']
+ wpsite = WPSites.objects.get(pk=WPManagerID)
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ path = wpsite.path
+
+ Webobj = Websites.objects.get(pk=wpsite.owner_id)
+
+ Vhuser = Webobj.externalApp
+ PHPVersion = Webobj.phpSelection
+ php = ACLManager.getPHPString(PHPVersion)
+ FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['Theme'] = Theme
+ extraArgs['FinalPHPPath'] = FinalPHPPath
+ extraArgs['path'] = path
+ extraArgs['Vhuser'] = Vhuser
+
+ background = ApplicationInstaller('ChangeStatusThemes', extraArgs)
+ background.start()
+
+ data_ret = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def CreateStagingNow(self, userID=None, data=None):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ extraArgs = {}
+ extraArgs['adminID'] = admin.pk
+ extraArgs['StagingDomain'] = data['StagingDomain']
+ extraArgs['StagingName'] = data['StagingName']
+ extraArgs['WPid'] = data['WPid']
+ extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
+
+ wpsite = WPSites.objects.get(pk=data['WPid'])
+
+ if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ background = ApplicationInstaller('CreateStagingNow', extraArgs)
+ background.start()
+
+ time.sleep(2)
+
+ data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
+ 'tempStatusPath': extraArgs['tempStatusPath']}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+
+ except BaseException as msg:
+ data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
def UpdateWPSettings(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -1990,748 +4009,6 @@ AuthUserFile {htpasswd}
Require valid-user"""
with open(htaccess, 'w') as f:
f.write(htaccess_content)
- 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:
- return JsonResponse({'status': 0, 'error_message': str(msg)})
-
- def submitWorpressCreation(self, userID=None, data=None):
- try:
- currentACL = ACLManager.loadedACL(userID)
- admin = Administrator.objects.get(pk=userID)
-
- 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)
-
- 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 = []
- try:
- wp_sites = WPSites.objects.filter(owner=website)
- wp_sites = [{
- 'id': wp.id,
- 'title': wp.title,
- '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:
- 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: