Merge branch 'v2.1.2' into v2.1.2-dev

This commit is contained in:
Usman Nasir
2022-03-20 22:50:22 +05:00
5 changed files with 99 additions and 15 deletions

View File

@@ -262,6 +262,11 @@ def getthemedata(request):
currentACL = ACLManager.loadedACL(val)
data = json.loads(request.body)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson('reboot', 0)
#logging.CyberCPLogFileWriter.writeToFile(str(data) + " [themedata]")
url = "https://raw.githubusercontent.com/usmannasir/CyberPanel-Themes/main/%s/design.css" % data['Themename']

View File

@@ -368,11 +368,14 @@ class backupUtilities:
## Stop making archive of document_root and copy instead
# copy_tree('/home/%s/public_html' % domainName, '%s/%s' % (tempStoragePath, 'public_html'))
from shutil import copytree
#copytree('/home/%s/public_html' % domainName, '%s/%s' % (tempStoragePath, 'public_html'))
command = f'cp -R /home/{domainName}/public_html {tempStoragePath}/public_html'
if ProcessUtilities.normalExecutioner(command) == 0:
raise BaseException(f'Failed to run {command}.')
raise BaseException(f'Failed to run cp command during backup generation.')
# make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html"))

View File

@@ -279,7 +279,19 @@ class cPanelImporter:
message = 'Restoring document root files for %s.' % (DomainName)
logging.statusWriter(self.logFile, message, 1)
self.homeDir = self.MainSite[4].replace('/home/%s/' % (self.MainSite[0]), '')
message = 'self.MainSite[4] %s.' % (self.MainSite[4])
logging.statusWriter(self.logFile, message, 1)
message = 'self.MainSite[0] %s.' % (self.MainSite[0])
logging.statusWriter(self.logFile, message, 1)
if self.MainSite[4].find('home/') > -1:
self.homeDir = self.MainSite[4].replace('/home/%s/' % (self.MainSite[0]), '')
else:
self.homeDir = self.MainSite[4].replace('/home2/%s/' % (self.MainSite[0]), '')
message = 'self.homeDir %s.' % (self.homeDir)
logging.statusWriter(self.logFile, message, 1)
nowPath = '/home/%s/public_html' % (DomainName)
if os.path.exists(nowPath):
@@ -387,7 +399,23 @@ class cPanelImporter:
message = 'Restoring document root files for %s.' % (items)
logging.statusWriter(self.logFile, message, 1)
ChildDocRoot = self.OtherDomains[counter][4].replace('/home/%s/' % (self.MainSite[0]), '')
message = 'self.OtherDomains[counter][4] %s.' % (self.OtherDomains[counter][4])
logging.statusWriter(self.logFile, message, 1)
message = 'self.MainSite[0] %s.' % (self.MainSite[0])
logging.statusWriter(self.logFile, message, 1)
if self.OtherDomains[counter][4].find('home/') > -1:
ChildDocRoot = self.OtherDomains[counter][4].replace('/home/%s/' % (self.MainSite[0]), '')
else:
ChildDocRoot = self.OtherDomains[counter][4].replace('/home2/%s/' % (self.MainSite[0]), '')
#ChildDocRoot = self.OtherDomains[counter][4].replace('/home/%s/' % (self.MainSite[0]), '')
message = 'ChildDocRoot %s.' % (ChildDocRoot)
logging.statusWriter(self.logFile, message, 1)
if os.path.exists(path):
shutil.rmtree(path)
@@ -863,7 +891,7 @@ class cPanelImporter:
if self.createCronJobs():
pass
else:
return 0
pass
self.RestoreEmails()
self.FixPermissions()

View File

@@ -910,9 +910,10 @@ class vhost:
else:
groupName = 'nogroup'
command = 'sudo -u %s chown %s:%s %s' % (virtualHostUser, virtualHostUser, groupName, path)
command = 'sudo -g %s -u %s chown %s:%s %s' % (groupName, virtualHostUser, virtualHostUser, groupName, path)
ProcessUtilities.normalExecutioner(command)
command = "sudo -u %s chmod 750 %s" % (virtualHostUser, path)
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)

View File

@@ -98,21 +98,21 @@ app.filter('getwebsitename', function () {
};
});
function getWebsiteName(domain){
function getWebsiteName(domain) {
if (domain !== undefined) {
domain = domain.replace(/-/g, '');
domain = domain.replace(/-/g, '');
var domainName = domain.split(".");
var domainName = domain.split(".");
var finalDomainName = domainName[0];
var finalDomainName = domainName[0];
if (finalDomainName.length > 5) {
finalDomainName = finalDomainName.substring(0, 4);
}
return finalDomainName;
if (finalDomainName.length > 5) {
finalDomainName = finalDomainName.substring(0, 4);
}
return finalDomainName;
}
}
app.controller('systemStatusInfo', function ($scope, $http, $timeout) {
@@ -655,3 +655,50 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
});
app.controller('designtheme', function ($scope, $http, $timeout) {
$scope.themeloading = true;
$scope.getthemedata = function () {
$scope.themeloading = false;
url = "/base/getthemedata";
var data = {
package: "helo world",
Themename: $('#stheme').val(),
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(Listgetthemedata, cantgetthemedata);
function Listgetthemedata(response) {
$scope.themeloading = true;
if (response.data.status === 1) {
document.getElementById('appendthemedata').innerHTML = "";
$("#appendthemedata").val(response.data.csscontent)
} else {
alert(response.data.error_message)
}
}
function cantgetthemedata(response) {
$scope.themeloading = true;
console.log(response);
}
//$timeout(getStuff, 2000);
};
});