bug fix: alias domains, php fetch and domain with sudo

This commit is contained in:
usmannasir
2024-02-09 17:58:28 +05:00
parent 24b10a3440
commit f28402cebb
12 changed files with 955 additions and 147 deletions

View File

@@ -27,6 +27,8 @@ class ChildDomains(models.Model):
path = models.CharField(max_length=200,default=None)
ssl = models.IntegerField()
phpSelection = models.CharField(max_length=10,default=None)
alais = models.IntegerField(default=0)
class Backups(models.Model):
website = models.ForeignKey(Websites,on_delete=models.CASCADE)

View File

@@ -4829,7 +4829,6 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
}
$scope.changePHP = function (childDomain, phpSelection) {
// notifcations
@@ -5775,12 +5774,15 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
$scope.showAliasForm = function (domainName) {
$scope.domainAliasForm = false;
$scope.aliasTable = true;
$scope.addAliasButton = true;
//$scope.domainAliasForm = false;
//$scope.aliasTable = true;
//$scope.addAliasButton = true;
masterDomain = domainName;
$scope.showCreateDomainForm();
$scope.masterDomain = domainName;
};
$scope.addAliasFunc = function () {
@@ -6010,6 +6012,641 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
};
////// create domain part
$("#domainCreationForm").hide();
$scope.showCreateDomainForm = function () {
$("#domainCreationForm").fadeIn();
};
$scope.hideDomainCreationForm = function () {
$("#domainCreationForm").fadeOut();
};
$scope.masterDomain = $("#domainNamePage").text();
// notifcations settings
$scope.domainLoading = true;
$scope.installationDetailsForm = false;
$scope.installationProgress = true;
$scope.errorMessageBox = true;
$scope.success = true;
$scope.couldNotConnect = true;
$scope.goBackDisable = true;
$scope.DomainCreateForm = true;
var statusFile;
$scope.webselection = true;
$scope.WebsiteType = function () {
var type = $scope.websitetype;
if (type == 'Sub Domain') {
$scope.webselection = false;
$scope.DomainCreateForm = true;
} else if (type == 'Addon Domain') {
$scope.DomainCreateForm = false;
$scope.webselection = true;
$scope.masterDomain = $('#defaultSite').html()
}
};
$scope.WebsiteSelection = function () {
$scope.DomainCreateForm = false;
};
$scope.createDomain = function () {
$scope.domainLoading = false;
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.errorMessageBox = true;
$scope.success = true;
$scope.couldNotConnect = true;
$scope.goBackDisable = true;
$scope.currentStatus = "Starting creation..";
$scope.DomainCreateForm = true;
var ssl, dkimCheck, openBasedir, apacheBackend;
if ($scope.sslCheck === true) {
ssl = 1;
} else {
ssl = 0
}
if ($scope.dkimCheck === true) {
dkimCheck = 1;
} else {
dkimCheck = 0
}
openBasedir = 0;
apacheBackend = 0
url = "/websites/submitDomainCreation";
var domainName = $scope.domainNameCreate;
var path = $scope.docRootPath;
if (typeof path === 'undefined') {
path = "";
}
var domainName = $scope.domainNameCreate;
var data = {
domainName: domainName,
ssl: ssl,
path: path,
masterDomain: $scope.masterDomain,
dkimCheck: 1,
openBasedir: 0,
alias: 1
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
// console.log(data)
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.createWebSiteStatus === 1) {
statusFile = response.data.tempStatusPath;
getCreationStatus();
} else {
$scope.domainLoading = true;
$scope.installationDetailsForm = true;
$scope.DomainCreateForm = true;
$scope.installationProgress = false;
$scope.errorMessageBox = false;
$scope.success = true;
$scope.couldNotConnect = true;
$scope.goBackDisable = false;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.domainLoading = true;
$scope.installationDetailsForm = true;
$scope.DomainCreateForm = true;
$scope.installationProgress = false;
$scope.errorMessageBox = true;
$scope.success = true;
$scope.couldNotConnect = false;
$scope.goBackDisable = false;
}
};
$scope.goBack = function () {
$scope.domainLoading = true;
$scope.installationDetailsForm = false;
$scope.DomainCreateForm = true;
$scope.installationProgress = true;
$scope.errorMessageBox = true;
$scope.success = true;
$scope.couldNotConnect = true;
$scope.goBackDisable = true;
$scope.DomainCreateForm = true;
$("#installProgress").css("width", "0%");
};
function getCreationStatus() {
url = "/websites/installWordpressStatus";
var data = {
statusFile: statusFile
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.abort === 1) {
if (response.data.installStatus === 1) {
$scope.domainLoading = true;
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.errorMessageBox = true;
$scope.success = false;
$scope.couldNotConnect = true;
$scope.goBackDisable = false;
$("#installProgress").css("width", "100%");
$scope.installPercentage = "100";
$scope.currentStatus = response.data.currentStatus;
$timeout.cancel();
fetchDomains();
} else {
$scope.domainLoading = true;
$scope.installationDetailsForm = true;
$scope.DomainCreateForm = true;
$scope.installationProgress = false;
$scope.errorMessageBox = false;
$scope.success = true;
$scope.couldNotConnect = true;
$scope.goBackDisable = false;
$scope.errorMessage = response.data.error_message;
$("#installProgress").css("width", "0%");
$scope.installPercentage = "0";
$scope.goBackDisable = false;
}
} else {
$("#installProgress").css("width", response.data.installationProgress + "%");
$scope.installPercentage = response.data.installationProgress;
$scope.currentStatus = response.data.currentStatus;
$timeout(getCreationStatus, 1000);
}
}
function cantLoadInitialDatas(response) {
$scope.domainLoading = true;
$scope.installationDetailsForm = true;
$scope.DomainCreateForm = true;
$scope.installationProgress = false;
$scope.errorMessageBox = true;
$scope.success = true;
$scope.couldNotConnect = false;
$scope.goBackDisable = false;
}
}
////// List Domains Part
////////////////////////
// notifcations
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.childBaseDirChanged = true;
fetchDomains();
$scope.showListDomains = function () {
fetchDomains();
$("#listDomains").fadeIn();
};
$scope.hideListDomains = function () {
$("#listDomains").fadeOut();
};
function fetchDomains() {
$scope.domainLoading = false;
var url = "/websites/fetchDomains";
var data = {
masterDomain: $("#domainNamePage").text(),
alias: 1
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.fetchStatus === 1) {
$scope.childDomains = JSON.parse(response.data.data);
$scope.domainLoading = true;
} else {
$scope.domainError = false;
$scope.errorMessage = response.data.error_message;
$scope.domainLoading = true;
}
}
function cantLoadInitialDatas(response) {
$scope.couldNotConnect = false;
}
}
$scope.changePHP = function (childDomain, phpSelection) {
// notifcations
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.domainLoading = false;
$scope.childBaseDirChanged = true;
var url = "/websites/changePHP";
var data = {
childDomain: childDomain,
phpSelection: phpSelection,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.changePHP === 1) {
$scope.domainLoading = true;
$scope.changedPHPVersion = phpSelection;
// notifcations
$scope.phpChanged = false;
$scope.domainError = true;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.childBaseDirChanged = true;
} else {
$scope.errorMessage = response.data.error_message;
$scope.domainLoading = true;
// notifcations
$scope.phpChanged = true;
$scope.domainError = false;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.childBaseDirChanged = true;
}
}
function cantLoadInitialDatas(response) {
$scope.domainLoading = true;
// notifcations
$scope.phpChanged = true;
$scope.domainError = false;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.childBaseDirChanged = true;
}
};
$scope.changeChildBaseDir = function (childDomain, openBasedirValue) {
// notifcations
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.domainLoading = false;
$scope.childBaseDirChanged = true;
var url = "/websites/changeOpenBasedir";
var data = {
domainName: childDomain,
openBasedirValue: openBasedirValue
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.changeOpenBasedir === 1) {
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.domainLoading = true;
$scope.childBaseDirChanged = false;
} else {
$scope.phpChanged = true;
$scope.domainError = false;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.domainLoading = true;
$scope.childBaseDirChanged = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = false;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.domainLoading = true;
$scope.childBaseDirChanged = true;
}
}
$scope.deleteChildDomain = function (childDomain) {
$scope.domainLoading = false;
// notifcations
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
url = "/websites/submitDomainDeletion";
var data = {
websiteName: childDomain,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.websiteDeleteStatus === 1) {
$scope.domainLoading = true;
$scope.deletedDomain = childDomain;
fetchDomains();
// notifications
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = true;
$scope.domainDeleted = false;
$scope.sslIssued = true;
} else {
$scope.errorMessage = response.data.error_message;
$scope.domainLoading = true;
// notifcations
$scope.phpChanged = true;
$scope.domainError = false;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
}
}
function cantLoadInitialDatas(response) {
$scope.domainLoading = true;
// notifcations
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = false;
$scope.domainDeleted = true;
$scope.sslIssued = true;
}
};
$scope.issueSSL = function (childDomain, path) {
$scope.domainLoading = false;
// notifcations
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.childBaseDirChanged = true;
var url = "/manageSSL/issueSSL";
var data = {
virtualHost: childDomain,
path: path,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.SSL === 1) {
$scope.domainLoading = true;
// notifcations
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = false;
$scope.childBaseDirChanged = true;
$scope.sslDomainIssued = childDomain;
} else {
$scope.domainLoading = true;
$scope.errorMessage = response.data.error_message;
// notifcations
$scope.phpChanged = true;
$scope.domainError = false;
$scope.couldNotConnect = true;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.childBaseDirChanged = true;
}
}
function cantLoadInitialDatas(response) {
// notifcations
$scope.phpChanged = true;
$scope.domainError = true;
$scope.couldNotConnect = false;
$scope.domainDeleted = true;
$scope.sslIssued = true;
$scope.childBaseDirChanged = true;
}
};
});
/* Java script code to manage cron ends here */

View File

@@ -3,144 +3,225 @@
{% block title %}{% trans "Domain Aliases - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div ng-controller="manageAliasController" class="container">
<div id="page-title">
<h2>{% trans "Domain Aliases" %}</h2>
<p>{% trans "With Domain Aliases you can visit example.com using example.net and view the same content." %}</p>
</div>
<div ng-controller="manageAliasController" class="container">
<div id="page-title">
<h2>{% trans "Domain Aliases" %}</h2>
<p>{% trans "With Domain Aliases you can visit example.com using example.net and view the same content." %}</p>
</div>
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Domain Aliases" %} <img ng-hide="manageAliasLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Domain Aliases" %} <img ng-hide="domainLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">
<span id="domainNamePage" style="display: none">{{ masterDomain }}</span>
<!------ Modification form that appears after a click --------------->
<div ng-hide="addAliasButton" class="form-group">
<div class="col-sm-4">
<button ng-click="showAliasForm('{{ masterDomain }}')" class="btn ra-100 btn-blue-alt">{% trans 'Create Alias' %}</button>
</div>
</div>
<table ng-hide="aliasTable" cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" ng-hide="aliasTable">
<thead>
<tr>
<th>{% trans "Master Domain" %}</th>
<th>{% trans "Alias" %}</th>
<th>{% trans "File System Path" %}</th>
<th>{% trans "SSL" %}</th>
<th>{% trans "Delete" %}</th>
</tr>
</thead>
<tbody>
<form action="/" class="form-horizontal bordered-row">
{% if noAlias == 1 %}
{% for alias in aliases %}
<tr>
<td>{{ masterDomain }}</td>
<td>{{ alias }}</td>
<td>{{ path }}</td>
<td><button type="button" ng-click="issueSSL('{{ masterDomain }}', '{{ alias }}')" class="btn ra-100 btn-purple">{% trans "Issue" %}</button></td>
<td>
<a class="btn btn-warning" ng-click="removeAlias('{{ masterDomain }}', '{{ alias }}')" href=""><i class="glyph-icon icon-trash" title="{% trans "Delete" %}"></i></a>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td>{{ masterDomain }}</td>
<td colspan="4">{% trans 'Domain Aliases not found.' %}</td>
</tr>
{% endif %}
</tbody>
</table>
<!------ Modification form that appears after a click --------------->
<div ng-hide="domainAliasForm">
<form action="/" class="form-horizontal bordered-row ng-scope ng-dirty ng-valid-parse ng-valid ng-valid-required">
<input type="hidden" ng-value="line" required="">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Alias Domain" %}</label>
<div class="col-sm-6">
<input ng-keypress="createAliasEnter($event)" type="text" class="form-control ng-pristine ng-untouched ng-not-empty ng-valid ng-valid-required" ng-model="aliasDomain" required="">
<!------ Modification form that appears after a click --------------->
<div ng-hide="addAliasButton" class="form-group">
<div class="col-sm-4">
<button ng-click="showAliasForm('{{ masterDomain }}')"
class="btn ra-100 btn-blue-alt">{% trans 'Create Alias' %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Additional Features" %}</label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input ng-model="sslCheck" type="checkbox" value="">
SSL
<div ng-show="sslCheck" style="margin-top: 2%;margin-bottom: -2%" class="alert alert-warning">
<p>{% trans "For SSL to work DNS of domain should point to server, otherwise self signed SSL will be issued, you can add your own SSL later." %}</p>
</div>
</label>
</form>
<!---------- HTML For creating domains --------------->
<div class="col-md-12 mx-10">
<form id="domainCreationForm" name="websiteCreationForm" action="/"
class="form-horizontal bordered-row">
<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="domainNameCreate" required>
</div>
<div style="margin-bottom: 1%;" class=" col-sm-1">
<a title="{% trans 'Cancel' %}" ng-click="hideDomainCreationForm()" href="">
<h3 class="glyph-icon icon-close text-danger mt-5"></h3>
</a>
</div>
</div>
<div ng-hide="installationDetailsForm" ng-hide="installationDetailsForm"
class="form-group">
<label class="col-sm-3 control-label">{% trans "Additional Features" %}</label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input ng-model="sslCheck" type="checkbox" value="">
SSL
</label>
</div>
</div>
<label class="col-sm-3 control-label"></label>
</div>
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="createDomain()"
class="btn btn-primary btn-lg">{% trans "Create Alias" %}</button>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-7">
<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>
<hr>
</form>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="addAliasFunc()" class="btn btn-primary btn-lg btn-block">{% trans "Create Alias" %}</button>
</div>
<div ng-hide="errorMessageBox" class="alert alert-danger">
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="success" class="alert alert-success">
<p>{% trans "Website succesfully created." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
</div>
<div style="margin-bottom: 1%" 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>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="aliasError" class="alert alert-danger">
<p>{% trans "Operation failed. Error message:" %} {$ errorMessage $}</p>
<!---------- HTML For creating domains --------------->
<!---------- HTML For Listing domains --------------->
<div id="listDomains" class="col-md-12 mx-10">
<form ng-hide="" class="form-horizontal bordered-row">
<div ng-hide="phpChanged" class="alert alert-success">
<p>{% trans "PHP Version Changed to:" %} {$ changedPHPVersion $} </p>
</div>
<div ng-hide="domainDeleted" class="alert alert-success">
<p>{% trans "Deleted:" %} {$ deletedDomain $} </p>
</div>
<div ng-hide="sslIssued" class="alert alert-success">
<p>{% trans "SSL Issued:" %} {$ sslDomainIssued $} </p>
</div>
<div ng-hide="childBaseDirChanged" class="alert alert-success">
<p>{% trans "Changes applied successfully." %} </p>
</div>
<div ng-hide="domainError" class="alert alert-danger">
<p>{$ errorMessage $}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="" class="form-group">
<div class="col-sm-11">
<input placeholder="Search Domain..." ng-model="logSearch" name="dom"
type="text" class="form-control" ng-model="domainNameCreate"
required>
</div>
<div ng-hide="aliasCreated" class="alert alert-success">
<p>{% trans "Alias successfully created. Refreshing page in 3 seconds..." %}</p>
<div style="margin-bottom: 1%;" class=" col-sm-1">
<a title="{% trans 'Close' %}" ng-click="hideListDomains()" href="">
<h3 class="glyph-icon icon-close text-danger mt-5"></h3>
</a>
</div>
<div ng-hide="operationSuccess" class="alert alert-success">
<p>{% trans "Operation Successfull." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
<div class="col-sm-12">
<table class="table">
<thead>
<tr>
<th>Domain</th>
<th>Launch</th>
<th>Path</th>
<th>SSL</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="record in childDomains | filter:logSearch">
<td ng-bind="record.childDomain"></td>
<td><a href="{$ record.childLunch $}"><img width="30px" height="30"
class="center-block"
src="{% static 'baseTemplate/assets/image-resources/webPanel.png' %}"></a>
</td>
<td ng-bind="record.path"></td>
<td>
<button type="button"
ng-click="issueSSL(record.childDomain,record.path)"
class="btn ra-50 btn-primary">{% trans "Issue" %}</button>
</td>
<td>
<button type="button"
ng-click="deleteChildDomain(record.childDomain)"
class="btn ra-50 btn-primary">{% trans "Delete" %}</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</form>
</div>
<!---------- HTML For Listing domains --------------->
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -2241,10 +2241,29 @@ class WebsiteManager:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
try:
alias = data['alias']
except:
alias = 0
masterDomain = data['masterDomain']
domain = data['domainName']
phpSelection = data['phpSelection']
path = data['path']
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):
@@ -2281,11 +2300,15 @@ class WebsiteManager:
if currentACL['admin'] != 1:
data['openBasedir'] = 1
if len(path) > 0:
path = path.lstrip("/")
path = "/home/" + masterDomain + "/" + path
if alias == 0:
if len(path) > 0:
path = path.lstrip("/")
path = "/home/" + masterDomain + "/" + path
else:
path = "/home/" + masterDomain + "/" + domain
else:
path = "/home/" + masterDomain + "/" + domain
path = f'/home/{masterDomain}/public_html'
try:
apacheBackend = str(data['apacheBackend'])
@@ -2298,7 +2321,7 @@ class WebsiteManager:
" --phpVersion '" + phpSelection + "' --ssl " + str(data['ssl']) + " --dkimCheck " + str(
data['dkimCheck']) \
+ " --openBasedir " + str(data['openBasedir']) + ' --path ' + path + ' --websiteOwner ' \
+ admin.userName + ' --tempStatusPath ' + tempStatusPath + " --apache " + apacheBackend
+ admin.userName + ' --tempStatusPath ' + tempStatusPath + " --apache " + apacheBackend + f' --aliasDomain {str(alias)}'
ProcessUtilities.popenExecutioner(execPath)
time.sleep(2)
@@ -2320,13 +2343,18 @@ class WebsiteManager:
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()
json_data = cdManager.findChildDomainsJson(alias)
final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json)
@@ -2441,7 +2469,7 @@ class WebsiteManager:
childDomains = []
for web in websites:
for child in web.childdomains_set.all():
for child in web.childdomains_set.filter(alais=0):
if child.domain == f'mail.{web.domain}':
pass
else:
@@ -3499,6 +3527,22 @@ class WebsiteManager:
website = Websites.objects.get(domain=self.domain)
website.phpSelection = data['phpSelection']
website.save()
### check if there are any alias domains under the main website and then change php for them too
for alias in website.childdomains_set.filter(alais=1):
try:
confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + alias.domain
completePathToConfigFile = confPath + "/vhost.conf"
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile
ProcessUtilities.popenExecutioner(execPath)
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(f'Error changing PHP for alias: {str(msg)}')
except:
website = ChildDomains.objects.get(domain=self.domain)
website.phpSelection = data['phpSelection']