diff --git a/cyberpanel.sh b/cyberpanel.sh index 04e058d90..c45f0a65a 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -610,13 +610,18 @@ fi check_root() { echo -e "\nChecking root privileges...\n" +if echo $(set) | grep SUDO > /dev/null ; then + echo -e "\nYou are using SUDO , please run as root user...\n" + exit +fi + if [[ $(id -u) != 0 ]] > /dev/null; then - echo -e "You must use root account to do this" - echo -e "or run following command: (do NOT miss the quotes)" - echo -e "\e[31msudo su -c \"sh <(curl https://cyberpanel.sh || wget -O - https://cyberpanel.sh)\"\e[39m" + echo -e "\nYou must use root user to install CyberPanel...\n" +# echo -e "or run following command: (do NOT miss the quotes)" +# echo -e "\e[31msudo su -c \"sh <(curl https://cyberpanel.sh || wget -O - https://cyberpanel.sh)\"\e[39m" exit 1 else - echo -e "You are runing as root...\n" + echo -e "\nYou are runing as root...\n" fi } diff --git a/filemanager/static/filemanager/js/fileManager.js b/filemanager/static/filemanager/js/fileManager.js index 067739616..69790bc3a 100755 --- a/filemanager/static/filemanager/js/fileManager.js +++ b/filemanager/static/filemanager/js/fileManager.js @@ -1481,10 +1481,10 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader, $scope.downloadFile = function () { - url = "/filemanager/downloadFile"; + url = "/filemanager/downloadFile/"; var downloadURL = $scope.currentPath + "/" + allFilesAndFolders[0]; - var indexPublicHTML = downloadURL.indexOf("public_html") + 11; - $window.location.href = '/preview/' + domainName + downloadURL.slice(indexPublicHTML); + + window.location.href = url + '?domainName=' + domainName + '?downloadURL=' + downloadURL; }; diff --git a/filemanager/views.py b/filemanager/views.py index 5170b8151..8e1852528 100755 --- a/filemanager/views.py +++ b/filemanager/views.py @@ -81,18 +81,26 @@ def changePermissions(request): def downloadFile(request): try: + userID = request.session['userID'] + admin = Administrator.objects.get(pk=userID) - data = json.loads(request.body) - fileToDownload = data['fileToDownload'] + fileToDownload = '/home/cyberpanel.xyz/public_html/hello.txt' + domainName = 'cyberpanel.xyz' - response = '' - if os.path.isfile(fileToDownload): - try: - with open(fileToDownload, 'rb') as f: - response = HttpResponse(f.read(), content_type="application/octet-stream") - response['Content-Disposition'] = 'inline; filename=' + os.path.basename(fileToDownload) - except Exception as e: - raise Http404 + currentACL = ACLManager.loadedACL(userID) + + if ACLManager.checkOwnership(domainName, admin, currentACL) == 1: + pass + else: + return ACLManager.loadErrorJson('permissionsChanged', 0) + + logging.CyberCPLogFileWriter.writeToFile('test') + + response = HttpResponse(content_type='application/force-download') + response['Content-Disposition'] = 'attachment; filename=%s' % (fileToDownload.split('/')[-1]) + response['X-LiteSpeed-Location'] = '%s' % (fileToDownload) + + logging.CyberCPLogFileWriter.writeToFile('test 2') return response except KeyError: