Skip to content

Commit

Permalink
Website App
Browse files Browse the repository at this point in the history
  • Loading branch information
zarakkhan209 committed Jan 20, 2024
1 parent 912746a commit 102a9a1
Show file tree
Hide file tree
Showing 13 changed files with 2,408 additions and 75 deletions.
167 changes: 167 additions & 0 deletions baseTemplate/templates/baseTemplate/FileManagerV2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{% extends "baseTemplate/newBase.html" %}
{% load i18n %}
{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %}
{% block newContent %}

<head>
<title>{% trans "File Manager - CyberPanel" %}</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

{% load static %}
<link rel="icon" type="image/png" href="{% static 'baseTemplate/assets/finalBase/favicon.png' %}">

<!-- Angular JS -->

<script src="https://code.angularjs.org/1.6.5/angular.min.js"></script>
<script src="{% static 'filemanager/js/fileManager.js' %}"></script>

<!-- Fix for old browsers -->
<script src="{% static 'filemanager/js/es5-shim.min.js' %}"></script>
<script src="{% static 'filemanager/js/es5-sham.min.js' %}"></script>
<script src="{% static 'filemanager/js/jquery-1.8.3.min.js' %}"></script>
<script src="{% static 'filemanager/js/console-sham.js' %}"></script>

<!--<script src="../bower_components/angular/angular.js"></script>-->
<script src="{% static 'filemanager/js/angular-file-upload.min.js' %}"></script>


<!-- HTML Editor Include -->

</head>

<div ng-app="fileManager" ng-controller="fileManagerCtrl" class="p-8">
<div class="flex py-2 px-6 items-center gap-4">
<div>
<p class="font-bold w-32">Current Path</p>
</div>
<div>
<input type="text" class="w-80 bg-gray-100 rounded px-2 py-1" id="currentRPath" ng-model="currentRPath"
readonly>
</div>
<div>
<ul class="list-group list-group-flush">
<li class="flex text-orange-500">
<a href="#" onclick="return false;" ng-click="fetchChilds($event,currentRPath,'primary')">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"/>
</svg>
</a>
<a onclick="return false;"
ng-click="fetchForTableSecondary($event,'fromTree',completeStartingPath)" href="#">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M2.25 12.75V12A2.25 2.25 0 0 1 4.5 9.75h15A2.25 2.25 0 0 1 21.75 12v.75m-8.69-6.44-2.12-2.12a1.5 1.5 0 0 0-1.061-.44H4.5A2.25 2.25 0 0 0 2.25 6v12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9a2.25 2.25 0 0 0-2.25-2.25h-5.379a1.5 1.5 0 0 1-1.06-.44Z"/>
</svg>
</a>
<a href="" class="ml-2">{$ startingPath $}</a>
</li>
</ul>
</div>
</div>
<div class="py-4">
<div>
<ul class="flex justify-between bg-blue-200 py-5 px-5 rounded-lg shadow-lg font-semibold">
<li>
<a onclick="return false;" ng-click="showUploadBox()" class="nav-link point-events" href="#"><i
class="fa fa-upload" aria-hidden="true"></i> {% trans "Upload" %}</a>
</li>
<li>
<a onclick="return false;" ng-click="showCreateFileModal()" class="nav-link point-events"
href="#"><i class="fa fa-plus-square" aria-hidden="true"></i> {% trans "New File" %}</a>
</li>
<li>
<a onclick="return false;" ng-click="showCreateFolderModal()" class="nav-link point-events"
href="#"><i class="fa fa-folder" aria-hidden="true"></i> {% trans "New Folder" %}</a>
</li>
<li id="deleteFile">
<a onclick="return false;" ng-click="showDeleteModal()" class="nav-link point-events"
href="#"><i
class="fa fa-trash-o" aria-hidden="true"></i> {% trans "Delete" %}</a>
</li>
<li id="copyFile">
<a onclick="return false;" ng-click="showCopyModal()" class="nav-link point-events" href="#"><i
class="fa fa-files-o" aria-hidden="true"></i> {% trans "Copy" %}</a>
</li>
<li id="moveFile">
<a onclick="return false;" ng-click="showMoveModal()" class="nav-link point-events" href="#"><i
class="fa fa-arrows-alt" aria-hidden="true"></i> {% trans "Move" %}</a>
</li>
<li id="renameFile">
<a onclick="return false;" ng-click="showRenameModal()" class="nav-link point-events"
href="#"><i
class="fa fa-file-text-o" aria-hidden="true"></i> {% trans "Rename" %}</a>
</li>
<li id="editFile">
<a onclick="return false;" ng-click="showHTMLEditorModal()" class="nav-link point-events"
href="#"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> {% trans "Edit" %}</a>
</li>
<li id="compressFile">
<a onclick="return false;" ng-click="showCompressionModal()" class="nav-link point-events"
href="#"><i
class="fa fa-compress" aria-hidden="true"></i> {% trans "Compress" %}</a>
</li>
<li id="extractFile">
<a onclick="return false;" ng-click="showExtractionModal()" class="nav-link point-events"
href="#"><i class="fa fa-expand" aria-hidden="true"></i> {% trans "Extract" %}</a>
</li>
</ul>
</div>
<div class="mt-2">
<ul class="flex py-5 px-5 gap-10 font-semibold">
<li>
<a onclick="return false;" ng-click="fetchForTableSecondary($event,'homeFetch')"
href="#"><i class="fa fa-home fa-lg" aria-hidden="true"></i> {% trans "Home" %}</a>
</li>
<li>
<a onclick="return false;" ng-click="fetchForTableSecondary($event,'goBackOnPath')"
href="#"><i class="fa fa-arrow-left fa-lg"
aria-hidden="true"></i> {% trans "Back" %}</a>
</li>

<li>
<a onclick="return false;" ng-click="fetchForTableSecondary($event,'refresh')"
href="#"><i class="fa fa-refresh fa-lg" aria-hidden="true"></i> {% trans "Refresh" %}</a>
</li>

<li>
<a onclick="return false;" ng-click="selectAll()" href="#"><i
class="fa fa-check-square-o fa-lg" aria-hidden="true"></i> {% trans "Select All" %}</a>
</li>

<li>
<a onclick="return false;" ng-click="unSelectAll()" href="#"><i
class="fa fa-square-o fa-lg" aria-hidden="true"></i> {% trans "UnSelect All" %}</a>
</li>
</ul>
</div>
<div>
<div class="relative py-5 overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right">
<thead id="tableHead">
<tr>
<th scope="col" class="px-6 py-3">
File Name
</th>
<th scope="col" class="px-6 py-3">
Size (KB)
</th>
<th scope="col" class="px-6 py-3">
Last Modified
</th>
<th scope="col" class="px-6 py-3">
Permissions
</th>
</tr>
</thead>
<tbody id="tableBodyFiles">
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions filemanager/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
url(r'^RootDownloadFile$',views.RootDownloadFile, name='RootDownloadFile'),
url(r'^editFile$', views.editFile, name='editFile'),
url('^Filemanager', views.FileManagerRoot, name='Filemanager'),
url('^V2/FilemanagerV2', views.FileManagerRootV2, name='FilemanagerV2'),
url(r'^(?P<domain>(.*))$', views.loadFileManagerHome, name='loadFileManagerHome'),

]
Expand Down
75 changes: 68 additions & 7 deletions filemanager/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from django.shortcuts import render,redirect
from django.shortcuts import render, redirect
from loginSystem.models import Administrator
from loginSystem.views import loadLoginPage
import plogical.CyberCPLogFileWriter as logging
Expand All @@ -8,9 +8,11 @@
from websiteFunctions.models import Websites
from plogical.acl import ACLManager
from .filemanager import FileManager as FM


# Create your views here.

def loadFileManagerHome(request,domain):
def loadFileManagerHome(request, domain):
try:
userID = request.session['userID']
if Websites.objects.filter(domain=domain).exists():
Expand All @@ -27,6 +29,7 @@ def loadFileManagerHome(request,domain):
except KeyError:
return redirect(loadLoginPage)


def changePermissions(request):
try:
userID = request.session['userID']
Expand Down Expand Up @@ -58,6 +61,7 @@ def changePermissions(request):
except KeyError:
return redirect(loadLoginPage)


def controller(request):
try:
data = json.loads(request.body)
Expand Down Expand Up @@ -128,6 +132,7 @@ def controller(request):
fm = FM(request, None)
return fm.ajaxPre(0, str(msg))


def upload(request):
try:

Expand All @@ -152,6 +157,7 @@ def upload(request):
except KeyError:
return redirect(loadLoginPage)


def editFile(request):
try:
userID = request.session['userID']
Expand Down Expand Up @@ -184,13 +190,15 @@ def editFile(request):
if ACLManager.checkOwnership(domainName, admin, currentACL) == 1:
return render(request, 'filemanager/editFile.html', {'domainName': domainName, 'fileName': fileName,
'mode': mode, 'modeFiles': modeFiles, 'theme': theme,
'themeFile': themeFile, 'additionalOptions': additionalOptions})
'themeFile': themeFile,
'additionalOptions': additionalOptions})
else:
return ACLManager.loadError()

except KeyError:
return redirect(loadLoginPage)


def FileManagerRoot(request):
### Load Custom CSS
try:
Expand All @@ -216,17 +224,17 @@ def FileManagerRoot(request):
url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
data = {
"name": "Filemanager",
"IP": ipAddressLocal
"IP": ipAddressLocal
}

import requests
response = requests.post(url, data=json.dumps(data))
Status = response.json()['status']

if(Status == 1):
if (Status == 1):
template = 'baseTemplate/FileManager.html'
else:
return redirect("https://cyberpanel.net/cyberpanel-addons")
return redirect("https://cyberpanel.net/cyberpanel-addons")
else:
template = 'baseTemplate/FileManager.html'
except BaseException as msg:
Expand All @@ -241,6 +249,58 @@ def FileManagerRoot(request):
proc = httpProc(request, template)
return proc.render()


def FileManagerRootV2(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()

userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddressLocal = ipData.split('\n', 1)[0]

try:

from plogical.processUtilities import ProcessUtilities
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:

url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
data = {
"name": "Filemanager",
"IP": ipAddressLocal
}

import requests
response = requests.post(url, data=json.dumps(data))
Status = response.json()['status']

if (Status == 1):
template = 'baseTemplate/FileManagerV2.html'
else:
return redirect("https://cyberpanel.net/cyberpanel-addons")
else:
template = 'baseTemplate/FileManagerV2.html'
except BaseException as msg:
template = 'baseTemplate/FileManagerV2.html'

if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson('FilemanagerAdmin', 0)

from plogical.httpProc import httpProc
proc = httpProc(request, template)
return proc.render()


def downloadFile(request):
try:
userID = request.session['userID']
Expand Down Expand Up @@ -274,6 +334,7 @@ def downloadFile(request):
except KeyError:
return redirect(loadLoginPage)


def RootDownloadFile(request):
try:
userID = request.session['userID']
Expand All @@ -295,6 +356,6 @@ def RootDownloadFile(request):
response['X-LiteSpeed-Location'] = '%s' % (fileToDownload)

return response
#return HttpResponse(response['X-LiteSpeed-Location'])
# return HttpResponse(response['X-LiteSpeed-Location'])
except KeyError:
return redirect(loadLoginPage)
Loading

0 comments on commit 102a9a1

Please sign in to comment.