Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Mar 11, 2021
1 parent c6e5de1 commit 1d18a1c
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 12 deletions.
3 changes: 1 addition & 2 deletions baseTemplate/templates/baseTemplate/index.html
Expand Up @@ -89,9 +89,8 @@
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/custom-js/pnotify.custom.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'websiteFunctions/websiteFunctions.css' %}">
<link rel="stylesheet" type="text/css" href="https://www.jsdelivr.com/package/npm/fontawesome">
<link rel="icon" type="image/png" href="{% static 'baseTemplate/assets/finalBase/favicon.png' %}">
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet"/>
<link type="text/css" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet"/>
{% block styles %}
{% endblock %}

Expand Down
13 changes: 11 additions & 2 deletions plogical/virtualHostUtilities.py
Expand Up @@ -1222,12 +1222,17 @@ def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck
return 0, str(msg)

@staticmethod
def deleteDomain(virtualHostName):
def deleteDomain(virtualHostName, DeleteDocRoot=0):
try:

numberOfWebsites = Websites.objects.count() + ChildDomains.objects.count()
vhost.deleteCoreConf(virtualHostName, numberOfWebsites)
delWebsite = ChildDomains.objects.get(domain=virtualHostName)

if DeleteDocRoot:
command = 'rm -rf %s' % (delWebsite.path)
ProcessUtilities.executioner(command)

delWebsite.delete()
installUtilities.installUtilities.reStartLiteSpeed()

Expand Down Expand Up @@ -1432,6 +1437,10 @@ def main():

parser.add_argument('--server', help='Switch server parameter.')

## Doc root deletion for child domain

parser.add_argument('--DeleteDocRoot', help='Doc root deletion for child domain.')

args = parser.parse_args()

if args.function == "createVirtualHost":
Expand Down Expand Up @@ -1524,7 +1533,7 @@ def main():
elif args.function == 'changeOpenBasedir':
virtualHostUtilities.changeOpenBasedir(args.virtualHostName, args.openBasedirValue)
elif args.function == 'deleteDomain':
virtualHostUtilities.deleteDomain(args.virtualHostName)
virtualHostUtilities.deleteDomain(args.virtualHostName, int(args.DeleteDocRoot))
elif args.function == 'switchServer':
virtualHostUtilities.switchServer(args.virtualHostName, args.phpVersion, int(args.server), args.tempStatusPath)

Expand Down
54 changes: 53 additions & 1 deletion static/websiteFunctions/websiteFunctions.js
Expand Up @@ -20,6 +20,7 @@ function getCookie(name) {
return cookieValue;
}


/* Java script code to create account */
app.controller('createWebsite', function ($scope, $http, $timeout, $window) {

Expand Down Expand Up @@ -388,7 +389,6 @@ app.controller('listWebsites', function ($scope, $http) {

app.controller('listChildDomainsMain', function ($scope, $http, $timeout) {


$scope.currentPage = 1;
$scope.recordsToShow = 10;

Expand Down Expand Up @@ -700,7 +700,59 @@ app.controller('listChildDomainsMain', function ($scope, $http, $timeout) {


}
var DeleteDomain;
$scope.deleteDomainInit = function (childDomainForDeletion){
DeleteDomain = childDomainForDeletion;
};

$scope.deleteChildDomain = function () {
$scope.cyberPanelLoading = false;
url = "/websites/submitDomainDeletion";

var data = {
websiteName: DeleteDomain,
DeleteDocRoot: $scope.DeleteDocRoot
};

var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};

$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);

function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.websiteDeleteStatus === 1) {
new PNotify({
title: 'Success!',
text: 'Child Domain successfully deleted.',
type: 'success'
});
$scope.getFurtherWebsitesFromDB();
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}


}

function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});

}

};

});

Expand Down
54 changes: 53 additions & 1 deletion websiteFunctions/static/websiteFunctions/websiteFunctions.js
Expand Up @@ -20,6 +20,7 @@ function getCookie(name) {
return cookieValue;
}


/* Java script code to create account */
app.controller('createWebsite', function ($scope, $http, $timeout, $window) {

Expand Down Expand Up @@ -388,7 +389,6 @@ app.controller('listWebsites', function ($scope, $http) {

app.controller('listChildDomainsMain', function ($scope, $http, $timeout) {


$scope.currentPage = 1;
$scope.recordsToShow = 10;

Expand Down Expand Up @@ -700,7 +700,59 @@ app.controller('listChildDomainsMain', function ($scope, $http, $timeout) {


}
var DeleteDomain;
$scope.deleteDomainInit = function (childDomainForDeletion){
DeleteDomain = childDomainForDeletion;
};

$scope.deleteChildDomain = function () {
$scope.cyberPanelLoading = false;
url = "/websites/submitDomainDeletion";

var data = {
websiteName: DeleteDomain,
DeleteDocRoot: $scope.DeleteDocRoot
};

var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};

$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);

function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.websiteDeleteStatus === 1) {
new PNotify({
title: 'Success!',
text: 'Child Domain successfully deleted.',
type: 'success'
});
$scope.getFurtherWebsitesFromDB();
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}


}

function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});

}

};

});

Expand Down
50 changes: 45 additions & 5 deletions websiteFunctions/templates/websiteFunctions/listChildDomains.html
Expand Up @@ -57,7 +57,7 @@ <h2 style="display: inline; color: #414C59;" ng-bind="web.domain"></h2>
</a>
<a target="_blank" href="/filemanager/{$ web.masterDomain $}" title="Open File Manager">
--
{$ web.path $}</a>
File Manager</a>
</div>
<div class="col-md-2 content-box-header" style="text-transform: none;">
<a href="/websites/{$ web.masterDomain $}/{$ web.domain $}" target="_blank"
Expand All @@ -69,9 +69,48 @@ <h2 style="display: inline; color: #414C59;" ng-bind="web.domain"></h2>
</div>
<div class="col-md-12">
<div class="col-md-4 content-box-header">
<i class="p fa fa-user-circle btn-icon text-muted" data-toggle="tooltip"
data-placement="right" title="Master Domain/Owner">&emsp;</i>
<span ng-bind="web.masterDomain" style="text-transform: none"></span>
<i class="p fa fa-trash-o btn-icon text-muted" data-toggle="tooltip"
data-placement="right"
title="Delete Child Domain">&emsp;</i>
<span><a ng-click='deleteDomainInit(web.domain)' data-toggle="modal" data-target="#DeleteChild" href=""
style="text-transform: none">Delete</a></span>
<div id="DeleteChild" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;
</button>
<h4 class="modal-title">Delete Child Domain
<img ng-hide="$parent.cyberPanelLoading"
src="/static/images/loading.gif"
style="display: none;">
</h4>
</div>
<div class="modal-body">
<form name="DeleteDocumentRootForm" action="/" class="form-horizontal">

<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-2 control-label">{% trans "" %}</label>
<div class="col-sm-8">
<input ng-model="$parent.DeleteDocRoot" type="checkbox" value="">
Delete Document Root
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary"
ng-click="deleteChildDomain()">Delete Now
</button>
<button type="button" ng-disabled="savingSettings"
class="btn btn-default" data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 content-box-header">
<i class="p fa fa-map-marker btn-icon text-muted" data-toggle="tooltip"
Expand Down Expand Up @@ -114,7 +153,8 @@ <h2 style="display: inline; color: #414C59;" ng-bind="web.domain"></h2>
<button type="button" class="close" data-dismiss="modal">&times;
</button>
<h4 class="modal-title">Convert Child Domain to normal Website
<img ng-hide="$parent.cyberPanelLoading" src="/static/images/loading.gif"
<img ng-hide="$parent.cyberPanelLoading"
src="/static/images/loading.gif"
style="display: none;">
</h4>
</div>
Expand Down
7 changes: 6 additions & 1 deletion websiteFunctions/website.py
Expand Up @@ -535,13 +535,18 @@ def submitDomainDeletion(self, userID=None, data=None):
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
execPath = execPath + " deleteDomain --virtualHostName " + websiteName + ' --DeleteDocRoot %s' % (str(DeleteDocRoot))
ProcessUtilities.outputExecutioner(execPath)

data_ret = {'status': 1, 'websiteDeleteStatus': 1, 'error_message': "None"}
Expand Down

0 comments on commit 1d18a1c

Please sign in to comment.