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

@@ -51,6 +51,7 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description='CyberPanel CloudLinux Manager')
parser.add_argument('-o', '--owner', help='Owner')
parser.add_argument('-n', '--name', help='Owner')
parser.add_argument('-p', '--with-php', help='False (X-Ray support only)')
args = parser.parse_args()

View File

@@ -533,7 +533,6 @@ class IncScheduler(multi.Thread):
if result.find(pid) > -1 and result.find('IncScheduler.py') > -1:
quit(1)
except:
### Save some important info in backup config
oldJobContinue = 0

View File

@@ -15,9 +15,9 @@ class ChildDomainManager:
self.masterDomain = masterDomain
self.childDomain = childDomain
def findChildDomainsJson(self):
def findChildDomainsJson(self, alias=0):
master = Websites.objects.get(domain=self.masterDomain)
childDomains = master.childdomains_set.all()
childDomains = master.childdomains_set.filter(alais=alias)
json_data = "["
checker = 0

View File

@@ -266,7 +266,7 @@ class phpUtilities:
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(result)
command = result + " -v | awk '/^PHP/ {print $2}'"
command = result + " -v 2>/dev/null | awk '/^PHP/ {print $2}'"
php_version = ProcessUtilities.outputExecutioner(command, None, True).rstrip('\n')
return f"PHP {php_version}"
@@ -291,8 +291,6 @@ class phpUtilities:
return PHPManager.findPHPVersions()[-2]
@staticmethod
def InstallSaidPHP(php):
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
@@ -305,10 +303,6 @@ class phpUtilities:
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')

View File

@@ -245,8 +245,9 @@ class ProcessUtilities(multi.Thread):
command = '%s-u %s %s' % (ProcessUtilities.token, user, command)
else:
command = '%s-u %s -d %s %s' % (ProcessUtilities.token, user, dir, command)
command = command.replace('sudo', '')
if command.startswith('sudo'):
command = command.replace('sudo', '', 1) # Replace 'sudo' with an empty string, only once
if os.path.exists(ProcessUtilities.debugPath):
if command.find('cat') == -1:

View File

@@ -37,6 +37,10 @@ class sslUtilities:
if san_extension:
# Extract and print the domains from SAN
san_domains = san_extension.value.get_values_for_type(x509.DNSName)
try:
logging.CyberCPLogFileWriter.writeToFile(f'Covered domains: {str(san_domains)}')
except:
pass
return 1, san_domains
else:
# If SAN is not present, return the Common Name as a fallback
@@ -54,19 +58,51 @@ class sslUtilities:
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, open(filePath, 'r').read())
SSLProvider = x509.get_issuer().get_components()[1][1].decode('utf-8')
if SSLProvider != 'Denial':
return sslUtilities.ISSUE_SSL
else:
status, domains = sslUtilities.getDomainsCovered(filePath)
#### totally seprate check to see if both non-www and www are covered
if SSLProvider == "Let's Encrypt":
status, domains = sslUtilities.getDomainsCovered(filePath)
if status:
if len(domains) > 1:
return sslUtilities.DONT_ISSUE
else:
return sslUtilities.ISSUE_SSL
### need further checks here to see if ssl is valid for less then 15 days etc
logging.CyberCPLogFileWriter.writeToFile(
'[CheckIfSSLNeedsToBeIssued] SSL exists for %s and both versions are covered, just need to ensure if SSL is valid for less then 15 days.' % (virtualHostName), 0)
pass
else:
return sslUtilities.ISSUE_SSL
#####
expireData = x509.get_notAfter().decode('ascii')
from datetime import datetime
finalDate = datetime.strptime(expireData, '%Y%m%d%H%M%SZ')
now = datetime.now()
diff = finalDate - now
if int(diff.days) >= 15 and SSLProvider!='Denial':
logging.CyberCPLogFileWriter.writeToFile(
'[CheckIfSSLNeedsToBeIssued] SSL exists for %s and is not ready to fetch new SSL., skipping..' % (
virtualHostName), 0)
return sslUtilities.DONT_ISSUE
elif SSLProvider == 'Denial':
logging.CyberCPLogFileWriter.writeToFile(
f'[CheckIfSSLNeedsToBeIssued] Self-signed SSL found, lets issue new SSL for {virtualHostName}', 0)
return sslUtilities.ISSUE_SSL
elif SSLProvider != "Let's Encrypt":
logging.CyberCPLogFileWriter.writeToFile(
f'[CheckIfSSLNeedsToBeIssued] Custom SSL found for {virtualHostName}', 0)
return sslUtilities.DONT_ISSUE
else:
logging.CyberCPLogFileWriter.writeToFile(
f'[CheckIfSSLNeedsToBeIssued] We will issue SSL for {virtualHostName}', 0)
return sslUtilities.ISSUE_SSL
else:
logging.CyberCPLogFileWriter.writeToFile(
f'[CheckIfSSLNeedsToBeIssued] We will issue SSL for {virtualHostName}', 0)
return sslUtilities.ISSUE_SSL
@staticmethod
def checkIfSSLMap(virtualHostName):
@@ -435,6 +471,7 @@ context /.well-known/acme-challenge {
@staticmethod
def obtainSSLForADomain(virtualHostName, adminEmail, sslpath, aliasDomain=None):
from plogical.acl import ACLManager
from plogical.sslv2 import sslUtilities as sslv2
import json

View File

@@ -2047,6 +2047,13 @@ CREATE TABLE `websiteFunctions_backupsv2` (`id` integer AUTO_INCREMENT NOT NULL
except:
pass
query = "ALTER TABLE `websiteFunctions_childdomains` ADD `alais` INT NOT NULL DEFAULT '0' AFTER `master_id`; "
try:
cursor.execute(query)
except:
pass
try:
connection.close()
except:

View File

@@ -1243,7 +1243,7 @@ class virtualHostUtilities:
@staticmethod
def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck, openBasedir, owner, apache,
tempStatusPath='/home/cyberpanel/fakePath', LimitsCheck=1):
tempStatusPath='/home/cyberpanel/fakePath', LimitsCheck=1, alias = 0):
try:
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Running some checks..,0')
@@ -1336,7 +1336,7 @@ class virtualHostUtilities:
if LimitsCheck:
website = ChildDomains(master=master, domain=virtualHostName, path=path, phpSelection=phpVersion,
ssl=ssl)
ssl=ssl, alais=alias)
website.save()
if ssl == 1:
@@ -1852,9 +1852,14 @@ def main():
except:
tempStatusPath = '/home/cyberpanel/fakePath'
try:
aliasDomain = int(args.aliasDomain)
except:
aliasDomain = 0
virtualHostUtilities.createDomain(args.masterDomain, args.virtualHostName, args.phpVersion, args.path,
int(args.ssl), dkimCheck, openBasedir, args.websiteOwner, apache,
tempStatusPath)
tempStatusPath, 1, aliasDomain)
elif args.function == "issueSSL":
virtualHostUtilities.issueSSL(args.virtualHostName, args.path, args.administratorEmail)
elif args.function == "issueSSLv2":

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">
<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>
<div class="panel">
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Domain Aliases" %} <img ng-hide="manageAliasLoading" src="{% static 'images/loading.gif' %}">
{% trans "Domain Aliases" %} <img ng-hide="domainLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<span id="domainNamePage" style="display: none">{{ masterDomain }}</span>
<form action="/" class="form-horizontal bordered-row">
<!------ 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>
<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>
{% if noAlias == 1 %}
<!---------- HTML For creating domains --------------->
<div class="col-md-12 mx-10">
<form id="domainCreationForm" name="websiteCreationForm" action="/"
class="form-horizontal bordered-row">
{% 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 ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Domain Name" %}</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="">
<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 class="form-group">
<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
<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>
</div>
</div>
<label class="col-sm-3 control-label"></label>
</div>
<hr>
</form>
<div class="form-group">
<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="addAliasFunc()" class="btn btn-primary btn-lg btn-block">{% trans "Create Alias" %}</button>
</div>
<button type="button" ng-click="createDomain()"
class="btn btn-primary btn-lg">{% trans "Create Alias" %}</button>
</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>
<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 ng-hide="aliasCreated" class="alert alert-success">
<p>{% trans "Alias successfully created. Refreshing page in 3 seconds..." %}</p>
<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 ng-hide="operationSuccess" class="alert alert-success">
<p>{% trans "Operation Successfull." %}</p>
<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>
<!---------- 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 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 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>
</form>
</div>
<!---------- HTML For Listing domains --------------->
</div>
</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']
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 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'])
@@ -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']