mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-10 15:26:13 +01:00
remove not needed function calls
This commit is contained in:
@@ -633,7 +633,9 @@
|
||||
<div style="position: absolute;top: 0;left: 0;" id="rightClick" class="card" style="width: 20rem;">
|
||||
<ul class="list-group list-group-flush">
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showMoveModal()" href="#"><li class="list-group-item"><i class="fa fa-arrows-alt" aria-hidden="true"></i> {% trans "Move" %}</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" id="downloadOnRight" onclick="return false;" ng-click="downloadFile()" href="#"><li class="list-group-item"><i class="fa fa-download" aria-hidden="true"></i> {% trans "Download" %}</li></a>
|
||||
{% comment %}
|
||||
<a style="border-bottom: 1px solid #007bff;" id="downloadOnRight" onclick="return false;" ng-click="RootDownloadFile()" href="#"><li class="list-group-item"><i class="fa fa-download" aria-hidden="true"></i> {% trans "Download" %}</li></a>
|
||||
{% endcomment %}
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showCopyModal()" href="#"><li class="list-group-item"><i class="fa fa-files-o" aria-hidden="true"></i> {% trans "Copy" %}</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showRenameModal()" href="#"><li class="list-group-item"><i class="fa fa-file-text-o" aria-hidden="true"></i> {% trans "Rename" %}</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showPermissionsModal()" href="#"><li class="list-group-item"><i class="fa fa-lock" aria-hidden="true"></i> {% trans "Change Permissions" %}</li></a>
|
||||
@@ -641,7 +643,9 @@
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showCompressionModal()" href="#"><li class="list-group-item"><i class="fa fa-compress" aria-hidden="true"></i> {% trans "Compress" %}</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" id="extractOnRight" onclick="return false;" ng-click="showExtractionModal()" href="#"><li class="list-group-item"><i class="fa fa-expand" aria-hidden="true"></i> {% trans "Extract" %}</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" id="editOnRight" onclick="return false;" ng-click="showHTMLEditorModal()" href="#"><li class="list-group-item"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> {% trans "Edit" %}</li></a>
|
||||
{% comment %}
|
||||
<a style="border-bottom: 1px solid #007bff;" id="editOnRightCodeMirror" onclick="return false;" ng-click="editWithCodeMirror()" href="#"><li class="list-group-item"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> {% trans "Edit with CodeMirror" %}</li></a>
|
||||
{% endcomment %}
|
||||
<a style="border-bottom: 1px solid #007bff;" id="restoreRight" onclick="return false;" ng-click="showRestoreModal()" href="#"><li class="list-group-item"><i class="fa fa-window-restore" aria-hidden="true"></i> {% trans "Restore" %}</li></a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -737,10 +737,10 @@
|
||||
<li class="header"><span>{% trans "Server" %}</span></li>
|
||||
<li>
|
||||
<a href="{% url 'Filemanager' %}"
|
||||
title="{% trans 'FileManager' %}">
|
||||
<i class="glyph-icon tooltip-button icon-link" title="{% trans 'FileManager' %}"
|
||||
title="{% trans 'Root File Manager' %}">
|
||||
<i class="glyph-icon tooltip-button icon-link" title="{% trans 'Root File Manager' %}"
|
||||
data-original-title=".icon-cloud-upload" aria-describedby="tooltip896208"></i>
|
||||
<span>{% trans "FileManager" %}</span>
|
||||
<span>{% trans "Root File Manager" %}</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
@@ -1588,6 +1588,12 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
|
||||
window.location.href = url + '?domainName=' + domainName + '&fileToDownload=' + downloadURL;
|
||||
};
|
||||
|
||||
$scope.RootDownloadFile = function () {
|
||||
url = "/filemanager/RootDownloadFile";
|
||||
var downloadURL = $scope.currentPath + "/" + allFilesAndFolders[0];
|
||||
window.location.href = url + '?fileToDownload=' + downloadURL;
|
||||
};
|
||||
|
||||
|
||||
// Change permissions
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ urlpatterns = [
|
||||
url(r'^changePermissions$',views.changePermissions, name='changePermissions'),
|
||||
url(r'^controller$',views.controller, name='controller'),
|
||||
url(r'^downloadFile$',views.downloadFile, name='downloadFile'),
|
||||
url(r'^RootDownloadFile$',views.RootDownloadFile, name='RootDownloadFile'),
|
||||
url(r'^editFile$', views.editFile, name='editFile'),
|
||||
url('^Filemanager', views.FileManagerRoot, name='Filemanager'),
|
||||
url(r'^(?P<domain>(.*))$', views.loadFileManagerHome, name='loadFileManagerHome'),
|
||||
|
||||
@@ -58,39 +58,6 @@ def changePermissions(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def downloadFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
from urllib.parse import quote
|
||||
from django.utils.encoding import iri_to_uri
|
||||
|
||||
fileToDownload = request.build_absolute_uri().split('fileToDownload')[1][1:]
|
||||
fileToDownload = iri_to_uri(fileToDownload)
|
||||
|
||||
domainName = request.GET.get('domainName')
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.checkOwnership(domainName, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('permissionsChanged', 0)
|
||||
|
||||
homePath = '/home/%s' % (domainName)
|
||||
|
||||
if fileToDownload.find('..') > -1 or fileToDownload.find(homePath) == -1:
|
||||
return HttpResponse("Unauthorized access.")
|
||||
|
||||
response = HttpResponse(content_type='application/force-download')
|
||||
response['Content-Disposition'] = 'attachment; filename=%s' % (fileToDownload.split('/')[-1])
|
||||
response['X-LiteSpeed-Location'] = '%s' % (fileToDownload)
|
||||
|
||||
return response
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def controller(request):
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
@@ -270,3 +237,61 @@ def FileManagerRoot(request):
|
||||
from plogical.httpProc import httpProc
|
||||
proc = httpProc(request, template)
|
||||
return proc.render()
|
||||
|
||||
def downloadFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
from urllib.parse import quote
|
||||
from django.utils.encoding import iri_to_uri
|
||||
|
||||
fileToDownload = request.build_absolute_uri().split('fileToDownload')[1][1:]
|
||||
fileToDownload = iri_to_uri(fileToDownload)
|
||||
|
||||
domainName = request.GET.get('domainName')
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.checkOwnership(domainName, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('permissionsChanged', 0)
|
||||
|
||||
homePath = '/home/%s' % (domainName)
|
||||
|
||||
if fileToDownload.find('..') > -1 or fileToDownload.find(homePath) == -1:
|
||||
return HttpResponse("Unauthorized access.")
|
||||
|
||||
response = HttpResponse(content_type='application/force-download')
|
||||
response['Content-Disposition'] = 'attachment; filename=%s' % (fileToDownload.split('/')[-1])
|
||||
response['X-LiteSpeed-Location'] = '%s' % (fileToDownload)
|
||||
|
||||
return response
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def RootDownloadFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
from urllib.parse import quote
|
||||
from django.utils.encoding import iri_to_uri
|
||||
|
||||
fileToDownload = request.build_absolute_uri().split('fileToDownload')[1][1:]
|
||||
fileToDownload = iri_to_uri(fileToDownload)
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
response = HttpResponse(content_type='application/force-download')
|
||||
response['Content-Disposition'] = 'attachment; filename=%s' % (fileToDownload.split('/')[-1])
|
||||
response['X-LiteSpeed-Location'] = '%s' % (fileToDownload)
|
||||
|
||||
return response
|
||||
#return HttpResponse(response['X-LiteSpeed-Location'])
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
Reference in New Issue
Block a user