mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-10 15:26:13 +01:00
filemanager0.1
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user