diff --git a/baseTemplate/templates/baseTemplate/FileManager.html b/baseTemplate/templates/baseTemplate/FileManager.html new file mode 100644 index 000000000..10c0d5f15 --- /dev/null +++ b/baseTemplate/templates/baseTemplate/FileManager.html @@ -0,0 +1,741 @@ +{% load i18n %} + + + + {% trans "File Manager - CyberPanel" %} + + + + + {% load static %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + +
+
+ +
+
+ +
+
+
+ +
+ + + + + + + + + + + + +
{% trans "File Name" %}{% trans "Size (KB)" %}{% trans "Last Modified" %}{% trans "Permissions" %}
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 3af0772fd..18d2ad160 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -333,6 +333,12 @@ data-original-title=".icon-comments-alt" aria-describedby="tooltip896208"> {% trans "Community" %} + + + {% trans "FileManager" %} + {% endif %} @@ -736,21 +742,23 @@
  • {% trans "Server" %}
  • -{#
  • #} -{# #} -{# #} -{# {% trans "Web Terminal" %}#} -{# {% trans "NEW" %}#} -{# #} -{# #} -{#
  • #} + + + {#
  • #} + {# #} + {# #} + {# {% trans "Web Terminal" %}#} + {# {% trans "NEW" %}#} + {# #} + {# #} + {#
  • #}
  • diff --git a/baseTemplate/urls.py b/baseTemplate/urls.py index ad11d2197..491d5baa1 100755 --- a/baseTemplate/urls.py +++ b/baseTemplate/urls.py @@ -8,6 +8,7 @@ urlpatterns = [ url(r'^getLoadAverage',views.getLoadAverage, name='getLoadAverage'), url(r'^versionManagment',views.versionManagment, name='versionManagment'), url(r'^design', views.design, name='design'), + url('^Filemanager', views.FileManager, name='Filemanager'), url(r'^getthemedata', views.getthemedata, name='getthemedata'), #url(r'^upgrade',views.upgrade, name='upgrade'), diff --git a/baseTemplate/views.py b/baseTemplate/views.py index ebca03522..bfef78bfc 100755 --- a/baseTemplate/views.py +++ b/baseTemplate/views.py @@ -281,3 +281,24 @@ def getthemedata(request): final_dic = {'status': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) + + +def FileManager(request): + ### Load Custom CSS + try: + from baseTemplate.models import CyberPanelCosmetic + cosmetic = CyberPanelCosmetic.objects.get(pk=1) + except: + from baseTemplate.models import CyberPanelCosmetic + cosmetic = CyberPanelCosmetic() + cosmetic.save() + + + + + template = 'baseTemplate/FileManager.html' + + + proc = httpProc(request, template,) + return proc.render() + diff --git a/filemanager/filemanager.py b/filemanager/filemanager.py index df8195510..3ae2c60dd 100755 --- a/filemanager/filemanager.py +++ b/filemanager/filemanager.py @@ -175,18 +175,31 @@ class FileManager: finalData = {} finalData['status'] = 1 - domainName = self.data['domainName'] - website = Websites.objects.get(domain=domainName) + try: - pathCheck = '/home/%s' % (domainName) + domainName = self.data['domainName'] + website = Websites.objects.get(domain=domainName) - if self.data['completeStartingPath'].find(pathCheck) == -1 or self.data['completeStartingPath'].find( - '..') > -1: - return self.ajaxPre(0, 'Not allowed to browse this path, going back home!') + pathCheck = '/home/%s' % (domainName) - command = "ls -la --group-directories-first " + self.returnPathEnclosed( - self.data['completeStartingPath']) - output = ProcessUtilities.outputExecutioner(command, website.externalApp).splitlines() + if self.data['completeStartingPath'].find(pathCheck) == -1 or self.data['completeStartingPath'].find( + '..') > -1: + return self.ajaxPre(0, 'Not allowed to browse this path, going back home!') + + command = "ls -la --group-directories-first " + self.returnPathEnclosed( + self.data['completeStartingPath']) + output = ProcessUtilities.outputExecutioner(command, website.externalApp).splitlines() + + except: + pathCheck = '/' + + if self.data['completeStartingPath'].find(pathCheck) == -1 or self.data['completeStartingPath'].find( + '..') > -1: + return self.ajaxPre(0, 'Not allowed to browse this path, going back home!') + + command = "ls -la --group-directories-first " + self.returnPathEnclosed( + self.data['completeStartingPath']) + output = ProcessUtilities.outputExecutioner(command).splitlines() counter = 0 for items in output: @@ -264,15 +277,25 @@ class FileManager: finalData = {} finalData['status'] = 1 - domainName = self.data['domainName'] - website = Websites.objects.get(domain=domainName) - homePath = '/home/%s' % (domainName) + try: - if self.data['fileName'].find('..') > -1 or self.data['fileName'].find(homePath) == -1: - return self.ajaxPre(0, 'Not allowed to move in this path, please choose location inside home!') + domainName = self.data['domainName'] + website = Websites.objects.get(domain=domainName) + homePath = '/home/%s' % (domainName) - command = "touch " + self.returnPathEnclosed(self.data['fileName']) - ProcessUtilities.executioner(command, website.externalApp) + if self.data['fileName'].find('..') > -1 or self.data['fileName'].find(homePath) == -1: + return self.ajaxPre(0, 'Not allowed to move in this path, please choose location inside home!') + + command = "touch " + self.returnPathEnclosed(self.data['fileName']) + ProcessUtilities.executioner(command, website.externalApp) + except: + homePath = '/' + + if self.data['fileName'].find('..') > -1 or self.data['fileName'].find(homePath) == -1: + return self.ajaxPre(0, 'Not allowed to move in this path, please choose location inside home!') + + command = "touch " + self.returnPathEnclosed(self.data['fileName']) + ProcessUtilities.executioner(command) self.changeOwner(self.returnPathEnclosed(self.data['fileName'])) @@ -280,7 +303,7 @@ class FileManager: return HttpResponse(json_data) except BaseException as msg: - return self.ajaxPre(0, str(msg)) + return self.ajaxPre(0, str("......."+msg)) def createNewFolder(self): try: diff --git a/filemanager/static/filemanager/js/fileManager.js b/filemanager/static/filemanager/js/fileManager.js index 834c16d11..853a70119 100755 --- a/filemanager/static/filemanager/js/fileManager.js +++ b/filemanager/static/filemanager/js/fileManager.js @@ -38,6 +38,10 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader, var domainName = $("#domainNameInitial").text(); var domainRandomSeed = ""; + $scope.currentRPath = "/"; + var homeRPathBack = ""; + + var homePathBack = "/home/" + domainName; $scope.currentPath = "/home/" + domainName; $scope.startingPath = domainName; @@ -631,23 +635,50 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader, url = "/filemanager/controller"; var completePathToFile = ""; - if (functionName === "startPoint") { - completePathToFile = $scope.currentPath; - } else if (functionName === "doubleClick") { - completePathToFile = $scope.currentPath + "/" + node.innerHTML; - } else if (functionName === "homeFetch") { - completePathToFile = homePathBack; - } else if (functionName === "goBackOnPath") { - var pos = $scope.currentPath.lastIndexOf("/"); - completePathToFile = $scope.currentPath.slice(0, pos); - } else if (functionName === "refresh") { - completePathToFile = $scope.currentPath; - var rightClickNode = document.getElementById("rightClick"); - } else if (functionName === "fromTree") { - completePathToFile = arguments[2]; + if (domainName === "") + { + completePathToFile = "/"; + if (functionName === "startPoint") { + completePathToFile = $scope.currentRPath; + } else if (functionName === "doubleClick") { + $scope.currentRPath = "" + completePathToFile = $scope.currentRPath + "/" + node.innerHTML; + } else if (functionName === "homeFetch") { + completePathToFile = homeRPathBack; + } else if (functionName === "goBackOnPath") { + var pos = $scope.currentRPath.lastIndexOf("/"); + completePathToFile = $scope.currentRPath.slice(0, pos); + } else if (functionName === "refresh") { + completePathToFile = $scope.currentRPath; + var rightClickNode = document.getElementById("rightClick"); + } else if (functionName === "fromTree") { + completePathToFile = arguments[2]; + } + $scope.currentRPath = completePathToFile; + + }else { + if (functionName === "startPoint") { + completePathToFile = $scope.currentPath; + } else if (functionName === "doubleClick") { + completePathToFile = $scope.currentPath + "/" + node.innerHTML; + } else if (functionName === "homeFetch") { + completePathToFile = homePathBack; + } else if (functionName === "goBackOnPath") { + var pos = $scope.currentPath.lastIndexOf("/"); + completePathToFile = $scope.currentPath.slice(0, pos); + } else if (functionName === "refresh") { + completePathToFile = $scope.currentPath; + var rightClickNode = document.getElementById("rightClick"); + } else if (functionName === "fromTree") { + completePathToFile = arguments[2]; + } + $scope.currentPath = completePathToFile; } - $scope.currentPath = completePathToFile; + + + + var data = { completeStartingPath: completePathToFile, @@ -951,9 +982,17 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader, }; $scope.createNewFile = function () { - - var completePathForFile = $scope.currentPath + "/" + $scope.newFileName; + if(domainName === "") + { + var completePathForFile = $scope.currentRPath + "/" + $scope.newFileName; $scope.errorMessageFile = true; + } + else { + var completePathForFile = $scope.currentPath + "/" + $scope.newFileName; + $scope.errorMessageFile = true; + } + + if ($scope.newFileName.length === 0) { $scope.errorMessageFile = false; diff --git a/filemanager/views.py b/filemanager/views.py index f9475b1e5..862967378 100755 --- a/filemanager/views.py +++ b/filemanager/views.py @@ -95,18 +95,21 @@ def downloadFile(request): def controller(request): try: data = json.loads(request.body) - domainName = data['domainName'] - method = data['method'] - userID = request.session['userID'] - admin = Administrator.objects.get(pk=userID) - currentACL = ACLManager.loadedACL(userID) + try: + domainName = data['domainName'] + method = data['method'] - if ACLManager.checkOwnership(domainName, admin, currentACL) == 1: - pass - else: - return ACLManager.loadErrorJson() + userID = request.session['userID'] + admin = Administrator.objects.get(pk=userID) + currentACL = ACLManager.loadedACL(userID) + if ACLManager.checkOwnership(domainName, admin, currentACL) == 1: + pass + else: + return ACLManager.loadErrorJson() + except: + print("habbi") fm = FM(request, data) if method == 'listForTable': diff --git a/plogical/IncScheduler.py b/plogical/IncScheduler.py index 4f6e361b9..ef38f429c 100644 --- a/plogical/IncScheduler.py +++ b/plogical/IncScheduler.py @@ -401,8 +401,6 @@ class IncScheduler(multi.Thread): break #print("new job started ") try: - Createtime =[] - page_token = None while True: response = drive.files().list(q="'%s' in parents"%(mainfolder_id),