mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 05:15:49 +01:00
feature: convert domain to website
This commit is contained in:
@@ -20,12 +20,14 @@ from plogical.mailUtilities import mailUtilities
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
|
||||
|
||||
class ApplicationInstaller(multi.Thread):
|
||||
|
||||
def __init__(self, installApp, extraArgs):
|
||||
multi.Thread.__init__(self)
|
||||
self.installApp = installApp
|
||||
self.extraArgs = extraArgs
|
||||
self.tempStatusPath = self.extraArgs['tempStatusPath']
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
@@ -45,10 +47,91 @@ class ApplicationInstaller(multi.Thread):
|
||||
self.installPrestaShop()
|
||||
elif self.installApp == 'magento':
|
||||
self.installMagento()
|
||||
elif self.installApp == 'convertDomainToSite':
|
||||
self.convertDomainToSite()
|
||||
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]')
|
||||
|
||||
def convertDomainToSite(self):
|
||||
try:
|
||||
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
import json, time
|
||||
|
||||
request = self.extraArgs['request']
|
||||
|
||||
##
|
||||
|
||||
statusFile = open(self.tempStatusPath, 'w')
|
||||
statusFile.writelines('Deleting domain as child..,20')
|
||||
statusFile.close()
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
domainName = data['domainName']
|
||||
|
||||
childDomain = ChildDomains.objects.get(domain=domainName)
|
||||
path = childDomain.path
|
||||
|
||||
wm = WebsiteManager()
|
||||
|
||||
wm.submitDomainDeletion(request.session['userID'], {'websiteName': domainName})
|
||||
time.sleep(5)
|
||||
|
||||
##
|
||||
|
||||
statusFile = open(self.tempStatusPath, 'w')
|
||||
statusFile.writelines('Creating domain as website..,40')
|
||||
statusFile.close()
|
||||
|
||||
resp = wm.submitWebsiteCreation(request.session['userID'], data)
|
||||
respData = json.loads(resp.content.decode('utf-8'))
|
||||
|
||||
##
|
||||
|
||||
while True:
|
||||
respDataStatus = ProcessUtilities.outputExecutioner("cat " + respData['tempStatusPath'])
|
||||
|
||||
if respDataStatus.find('[200]') > -1:
|
||||
break
|
||||
elif respDataStatus.find('[404]') > -1:
|
||||
statusFile = open(self.tempStatusPath, 'w')
|
||||
statusFile.writelines(respDataStatus['currentStatus'] + ' [404]')
|
||||
statusFile.close()
|
||||
return 0
|
||||
else:
|
||||
statusFile = open(self.tempStatusPath, 'w')
|
||||
statusFile.writelines(respDataStatus)
|
||||
statusFile.close()
|
||||
time.sleep(1)
|
||||
|
||||
statusFile = open(self.tempStatusPath, 'w')
|
||||
statusFile.writelines('Moving data..,80')
|
||||
statusFile.close()
|
||||
|
||||
|
||||
command = 'rm -rf /home/%s/public_html' % (domainName)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'mv %s /home/%s/public_html' % (path, domainName)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
website = Websites.objects.get(domain=domainName)
|
||||
|
||||
command = 'chown %s:%s /home/%s/public_html' % (website.externalApp, website.externalApp, domainName)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
statusFile = open(self.tempStatusPath, 'w')
|
||||
statusFile.writelines('Successfully converted. [200]')
|
||||
statusFile.close()
|
||||
|
||||
except BaseException as msg:
|
||||
statusFile = open(self.tempStatusPath, 'w')
|
||||
statusFile.writelines(str(msg) + " [404]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
def installWPCLI(self):
|
||||
try:
|
||||
command = 'sudo wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
||||
|
||||
@@ -378,7 +378,7 @@ app.controller('listWebsites', function ($scope, $http) {
|
||||
|
||||
});
|
||||
|
||||
app.controller('listChildDomainsMain', function ($scope, $http) {
|
||||
app.controller('listChildDomainsMain', function ($scope, $http, $timeout) {
|
||||
|
||||
|
||||
$scope.currentPage = 1;
|
||||
@@ -525,6 +525,174 @@ app.controller('listChildDomainsMain', function ($scope, $http) {
|
||||
|
||||
};
|
||||
|
||||
$scope.initConvert = function(virtualHost){
|
||||
$scope.domainName = virtualHost;
|
||||
};
|
||||
|
||||
var statusFile;
|
||||
|
||||
$scope.installationProgress = true;
|
||||
|
||||
$scope.convert = function () {
|
||||
|
||||
$scope.cyberPanelLoading = false;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
$scope.currentStatus = "Starting creation..";
|
||||
|
||||
var ssl, dkimCheck, openBasedir;
|
||||
|
||||
if ($scope.sslCheck === true) {
|
||||
ssl = 1;
|
||||
} else {
|
||||
ssl = 0
|
||||
}
|
||||
|
||||
if ($scope.dkimCheck === true) {
|
||||
dkimCheck = 1;
|
||||
} else {
|
||||
dkimCheck = 0
|
||||
}
|
||||
|
||||
if ($scope.openBasedir === true) {
|
||||
openBasedir = 1;
|
||||
} else {
|
||||
openBasedir = 0
|
||||
}
|
||||
|
||||
url = "/websites/convertDomainToSite";
|
||||
|
||||
|
||||
var data = {
|
||||
package: $scope.packageForWebsite,
|
||||
domainName: $scope.domainName,
|
||||
adminEmail: $scope.adminEmail,
|
||||
phpSelection: $scope.phpSelection,
|
||||
websiteOwner: $scope.websiteOwner,
|
||||
ssl: ssl,
|
||||
dkimCheck: dkimCheck,
|
||||
openBasedir: openBasedir
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.createWebSiteStatus === 1) {
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getCreationStatus();
|
||||
} else {
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
$scope.goBack = function () {
|
||||
$scope.cyberPanelLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.goBackDisable = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
function getCreationStatus() {
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.abort === 1) {
|
||||
|
||||
if (response.data.installStatus === 1) {
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
} else {
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.currentStatus = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout(getCreationStatus, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -55,10 +55,13 @@
|
||||
<a href="http://{$ web.domain $}" target="_blank" title="Visit Site">
|
||||
<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>
|
||||
<a target="_blank" href="/filemanager/{$ web.masterDomain $}" title="Open File Manager">
|
||||
--
|
||||
{$ web.path $}</a>
|
||||
</div>
|
||||
<div class="col-md-2 content-box-header" style="text-transform: none;">
|
||||
<a href="/websites/{$ web.domain $}" target="_blank" title="Manage Website">
|
||||
<a href="/websites/{$ web.masterDomain $}/{$ web.domain $}" target="_blank"
|
||||
title="Manage Website">
|
||||
<i class="p fa fa-external-link btn-icon"> </i>
|
||||
<span>Manage</span>
|
||||
</a>
|
||||
@@ -78,13 +81,15 @@
|
||||
<div class="col-md-4 content-box-header">
|
||||
<i class="p fa fa-lock btn-icon text-muted" data-toggle="tooltip" data-placement="right"
|
||||
title="SSL"> </i>
|
||||
<span><a ng-click="issueSSL(web.domain)" href="" style="text-transform: none">Issue SSL</a></span>
|
||||
<span><a ng-click="issueSSL(web.domain)" href=""
|
||||
style="text-transform: none">Issue SSL</a></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="col-md-4 content-box-header">
|
||||
<i class="p fa fa-cubes btn-icon text-muted" data-toggle="tooltip" data-placement="right"
|
||||
<i class="p fa fa-cubes btn-icon text-muted" data-toggle="tooltip"
|
||||
data-placement="right"
|
||||
title="Packages"> </i>
|
||||
<span ng-bind="web.package" style="text-transform: none"></span>
|
||||
</div>
|
||||
@@ -95,33 +100,134 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 content-box-header">
|
||||
<i class="p fa fa-arrows-h btn-icon text-muted" data-toggle="tooltip" data-placement="right"
|
||||
<i class="p fa fa-arrows-h btn-icon text-muted" data-toggle="tooltip"
|
||||
data-placement="right"
|
||||
title="Convert to Website"> </i>
|
||||
<span><a ng-click="issueSSL(web.domain)" href="" style="text-transform: none">Convert to Website</a></span>
|
||||
<span><a data-toggle="modal" data-target="#settings" href=""
|
||||
style="text-transform: none" ng-click="initConvert(web.domain)">Convert to Website</a></span>
|
||||
<div id="settings" 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">×
|
||||
</button>
|
||||
<h4 class="modal-title">Convert Child Domain to normal Website
|
||||
<img ng-hide="$parent.cyberPanelLoading" src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Domain Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="dom" type="text" class="form-control"
|
||||
ng-model="domainName"
|
||||
placeholder="{% trans "Do not enter WWW, it will be auto created!" %}"
|
||||
readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Owner" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="$parent.websiteOwner"
|
||||
class="form-control">
|
||||
{% for items in owernList %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr ng-hide="installationDetailsForm">
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Package" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="$parent.packageForWebsite"
|
||||
class="form-control">
|
||||
{% for items in packageList %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr ng-hide="installationDetailsForm">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Email" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="email" name="email" class="form-control"
|
||||
ng-model="$parent.adminEmail" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr ng-hide="installationDetailsForm">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select PHP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="$parent.phpSelection"
|
||||
class="form-control">
|
||||
{% for php in phps %}
|
||||
<option>{{ php }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-1 control-label"></label>
|
||||
<div class="col-sm-10">
|
||||
|
||||
<div class="alert alert-success text-center">
|
||||
<h2>{$ currentStatus $}</h2>
|
||||
</div>
|
||||
|
||||
<div class="progress">
|
||||
<div id="installProgress" class="progress-bar"
|
||||
role="progressbar" aria-valuenow="70"
|
||||
aria-valuemin="0" aria-valuemax="100"
|
||||
style="width:0%">
|
||||
<span class="sr-only">70% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-disabled="goBackDisable"
|
||||
ng-click="goBack()"
|
||||
class="btn btn-primary btn-lg">{% trans "Go Back" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary"
|
||||
ng-click="convert()">Convert
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!--table cellpadding="0" cellspacing="0" border="0" class="table" style="margin:0px 0px; id="datatable-example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP Address</th>
|
||||
<th>Package</th>
|
||||
<th>Owner</th>
|
||||
<th>State</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td ng-bind="web.ipAddress"></td>
|
||||
<td ng-bind="web.package"></td>
|
||||
<td ng-bind="web.admin"></td>
|
||||
<td ng-bind="web.state"></td>
|
||||
<td ng-bind="web.adminEmail"></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table-->
|
||||
|
||||
</div>
|
||||
|
||||
@@ -147,5 +253,5 @@
|
||||
</div> <!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -20,6 +20,7 @@ urlpatterns = [
|
||||
url(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'),
|
||||
url(r'^fetchWebsitesList$', views.fetchWebsitesList, name='fetchWebsitesList'),
|
||||
url(r'^fetchChildDomainsMain$', views.fetchChildDomainsMain, name='fetchChildDomainsMain'),
|
||||
url(r'^convertDomainToSite$', views.convertDomainToSite, name='convertDomainToSite'),
|
||||
url(r'^searchWebsites$', views.searchWebsites, name='searchWebsites'),
|
||||
url(r'^submitWebsiteModification$', views.deleteWebsite, name='submitWebsiteModification'),
|
||||
url(r'^submitWebsiteStatus$', views.submitWebsiteStatus, name='submitWebsiteStatus'),
|
||||
|
||||
@@ -189,6 +189,16 @@ def submitDomainDeletion(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def convertDomainToSite(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.convertDomainToSite(userID, request)
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def submitWebsiteStatus(request):
|
||||
try:
|
||||
|
||||
|
||||
@@ -119,8 +119,13 @@ class WebsiteManager:
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
pagination = self.websitePagination(currentACL, userID)
|
||||
adminNames = ACLManager.loadAllUsers(userID)
|
||||
packagesName = ACLManager.loadPackages(userID, currentACL)
|
||||
phps = PHPManager.findPHPVersions()
|
||||
|
||||
return render(request, 'websiteFunctions/listChildDomains.html', {"pagination": pagination})
|
||||
Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
|
||||
|
||||
return render(request, 'websiteFunctions/listChildDomains.html', Data)
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -2739,3 +2744,22 @@ StrictHostKeyChecking no
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def convertDomainToSite(self, userID=None, request=None):
|
||||
try:
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['request'] = request
|
||||
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
background = ApplicationInstaller('convertDomainToSite', extraArgs)
|
||||
background.start()
|
||||
|
||||
data_ret = {'status': 1, 'createWebSiteStatus': 1, 'tempStatusPath': extraArgs['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)
|
||||
Reference in New Issue
Block a user