From 5b72b8c3bc7591e8f33e982356250df603b2b5ae Mon Sep 17 00:00:00 2001 From: Zarak Khan Date: Thu, 25 Jan 2024 21:46:57 +0500 Subject: [PATCH] File Manager App --- .../templates/baseTemplate/newBase.html | 4 +- .../static/emailPremium/emailPremiumV2.js | 301 +++ .../emailPremium/EmailDebuggerV2.html | 252 +++ emailPremium/urls.py | 1 + emailPremium/views.py | 59 +- .../static/filemanager/js/fileManagerV2.js | 1819 +++++++++++++++++ .../templates/filemanager/indexv2.html | 427 +++- .../templates/mailServer/listEmailsV2.html | 268 ++- .../templates/packages/listPackagesV2.html | 87 +- .../websiteFunctions/installWordPressV2.html | 6 +- 10 files changed, 3020 insertions(+), 204 deletions(-) create mode 100644 emailPremium/static/emailPremium/emailPremiumV2.js create mode 100644 emailPremium/templates/emailPremium/EmailDebuggerV2.html create mode 100644 filemanager/static/filemanager/js/fileManagerV2.js diff --git a/baseTemplate/templates/baseTemplate/newBase.html b/baseTemplate/templates/baseTemplate/newBase.html index 77f816a59..06c795f27 100644 --- a/baseTemplate/templates/baseTemplate/newBase.html +++ b/baseTemplate/templates/baseTemplate/newBase.html @@ -678,7 +678,7 @@ DKIM Manager
  • - • Email Debugger
  • @@ -1676,6 +1676,8 @@ + + \ No newline at end of file diff --git a/emailPremium/static/emailPremium/emailPremiumV2.js b/emailPremium/static/emailPremium/emailPremiumV2.js new file mode 100644 index 000000000..e4e1666c6 --- /dev/null +++ b/emailPremium/static/emailPremium/emailPremiumV2.js @@ -0,0 +1,301 @@ +newapp.controller('EmailDebuugerV2', function ($scope, $http, $timeout, $window) { + + $scope.cyberpanelLoading = true; + $scope.ExecutionStatus = true; + $scope.ReportStatus = true; + + + $scope.RunServerLevelEmailChecks = function () { + $scope.cyberpanelLoading = false; + + var url = "/emailPremium/RunServerLevelEmailChecks"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + statusFile = response.data.tempStatusPath; + reportFile = response.data.reportFile; + statusFunc(); + + + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + + new PNotify({ + title: 'Error', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + }; + + function statusFunc() { + $scope.cyberpanelLoading = false; + $scope.ExecutionStatus = false; + var url = "/emailPremium/statusFunc"; + + var data = { + statusFile: statusFile + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + if (response.data.status === 1) { + if (response.data.abort === 1) { + $scope.functionProgress = {"width": "100%"}; + $scope.functionStatus = response.data.currentStatus; + $scope.cyberpanelLoading = true; + $scope.ReadReport(); + $timeout.cancel(); + } else { + $scope.functionProgress = {"width": response.data.installationProgress + "%"}; + $scope.functionStatus = response.data.currentStatus; + $timeout(statusFunc, 3000); + } + + } else { + $scope.cyberpanelLoading = true; + $scope.functionStatus = response.data.error_message; + $scope.functionProgress = {"width": response.data.installationProgress + "%"}; + $timeout.cancel(); + } + + } + + function cantLoadInitialData(response) { + $scope.functionProgress = {"width": response.data.installationProgress + "%"}; + $scope.functionStatus = 'Could not connect to server, please refresh this page.'; + $timeout.cancel(); + } + } + + $scope.ReadReport = function () { + + if (reportFile === 'none') { + return; + } + + $scope.cyberpanelLoading = false; + + var url = "/emailPremium/ReadReport"; + + var data = { + reportFile: reportFile + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + var reportResult = JSON.parse(response.data.reportContent); + + if (reportResult.MailSSL === 1) { + $scope.MailSSL = 'Issued and Valid'; + } else { + $scope.MailSSL = 'Not issued or expired.' + } + var report = response.data.report; + + console.log(report); + $scope.Port25 = report.Port25; + $scope.Port587 = report.Port587; + $scope.Port465 = report.Port465; + $scope.Port110 = report.Port110; + $scope.Port143 = report.Port143; + $scope.Port993 = report.Port993; + $scope.Port995 = report.Port995; + //document.getElementById('MailSSLURL').href = 'https://' + report.serverHostName + ":" + report.port + '/cloudAPI/access?token=' + report.token + "&serverUserName=" + report.userName + '&redirect=/manageSSL/sslForMailServer'; + document.getElementById('MailSSLURL').href = '/manageSSL/sslForMailServer'; + + + $scope.ReportStatus = false; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Error', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + + + }; + + $scope.ResetEmailConfigurations = function () { + $scope.cyberpanelLoading = false; + + var url = "/emailPremium/ResetEmailConfigurations"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + statusFile = response.data.tempStatusPath; + reportFile = response.data.reportFile; + reportFile = 'none'; + statusFunc(); + + + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + + new PNotify({ + title: 'Error', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + }; + +}); + +newapp.controller('emailDebuggerDomainLevelV2', function ($scope, $http, $timeout, $window) { + $scope.cyberpanelLoading = true; + $scope.ReportStatus = true; + + $scope.debugEmailForSite = function () { + $scope.cyberpanelLoading = false; + + url = "/emailPremium/debugEmailForSite"; + + var data = { + websiteName: $scope.websiteName + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + $scope.status = response.data.status; + $scope.message = response.data.error_message; + $scope.ReportStatus = false; + + } + + function cantLoadInitialData(response) { + $scope.cyberhosting = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + + }; + + $scope.fixMailSSL = function () { + $scope.cyberpanelLoading = false; + url = "/emailPremium/fixMailSSL"; + + var data = { + websiteName: $scope.websiteName + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + + new PNotify({ + title: 'Success', + text: 'Successfully fixed.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + }; + +}); \ No newline at end of file diff --git a/emailPremium/templates/emailPremium/EmailDebuggerV2.html b/emailPremium/templates/emailPremium/EmailDebuggerV2.html new file mode 100644 index 000000000..79d76c85b --- /dev/null +++ b/emailPremium/templates/emailPremium/EmailDebuggerV2.html @@ -0,0 +1,252 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
    +
    +

    Email Debugger

    +

    Email debugger to fix server-wide or website level email + settings.

    +
    +
    +
    +

    DEBUG EMAIL SERVER

    + +
    +
    + +
    + + +
    +
    +
    +

    WEBSITE LEVEL EMAIL ISSUES

    + +
    +
    +
    +
    +

    Websites

    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + +
    + Status + + Actions +
    + {$ message $} + + + +
    +
    +
    + +
    +

    {$ functionStatus $}

    + +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Issue + + Status + + Actions +
    + Mail Server SSL + + {$ MailSSL $} + + + + +
    + Port 25 + + {$ Port25 $} + + + + +
    + Port 587 + + {$ Port587 $} + + + + +
    + Port 465 + + {$ Port465 $} + + + + +
    + Port 110 + + {$ Port110 $} + + + + +
    + Port 143 + + {$ Port143 $} + + + + +
    + Port 995 + + {$ Port995 $} + + + + +
    + Port 993 + + {$ Port993 $} + + + + +
    +
    +
    +
    +{% endblock %} diff --git a/emailPremium/urls.py b/emailPremium/urls.py index ba29c3fd2..363a1e3ee 100755 --- a/emailPremium/urls.py +++ b/emailPremium/urls.py @@ -59,6 +59,7 @@ urlpatterns = [ url(r'^RestartRspamd$', views.RestartRspamd, name='RestartRspamd'), url(r'^EmailDebugger$', views.EmailDebugger, name='EmailDebugger'), + url(r'^V2/EmailDebuggerV2$', views.EmailDebuggerV2, name='EmailDebuggerV2'), url(r'^RunServerLevelEmailChecks$', views.RunServerLevelEmailChecks, name='RunServerLevelEmailChecks'), url(r'^ResetEmailConfigurations$', views.ResetEmailConfigurations, name='ResetEmailConfigurations'), diff --git a/emailPremium/views.py b/emailPremium/views.py index 566ef17d6..4d50eb81a 100755 --- a/emailPremium/views.py +++ b/emailPremium/views.py @@ -1260,6 +1260,7 @@ def Rspamd(request): else: return redirect("https://cyberpanel.net/cyberpanel-addons") + def installRspamd(request): try: userID = request.session['userID'] @@ -1298,6 +1299,7 @@ def installRspamd(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def installStatusRspamd(request): try: userID = request.session['userID'] @@ -1321,7 +1323,7 @@ def installStatusRspamd(request): 'abort': 1, 'installed': 1, }) - cmd = 'rm -f %s'%mailUtilities.RspamdInstallLogPath + cmd = 'rm -f %s' % mailUtilities.RspamdInstallLogPath ProcessUtilities.executioner(cmd) return HttpResponse(final_json) @@ -1355,6 +1357,7 @@ def installStatusRspamd(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def fetchRspamdSettings(request): try: userID = request.session['userID'] @@ -1487,14 +1490,14 @@ def fetchRspamdSettings(request): read_servers = j[1] # logging.CyberCPLogFileWriter.writeToFile(str(read_servers) + "read_servers") - #ClamAV configs + # ClamAV configs clamav_Debug = True LogFile = '' TCPAddr = '' TCPSocket = '' - if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: clamavconfpath = '/etc/clamd.d/scan.conf' elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: clamavconfpath = "/etc/clamav/clamd.conf" @@ -1518,7 +1521,6 @@ def fetchRspamdSettings(request): else: clamav_Debug = True - final_dic = {'fetchStatus': 1, 'installed': 1, 'enabled': enabled, @@ -1553,6 +1555,7 @@ def fetchRspamdSettings(request): except KeyError: return redirect(loadLoginPage) + def saveRspamdConfigurations(request): try: userID = request.session['userID'] @@ -1589,6 +1592,7 @@ def saveRspamdConfigurations(request): except KeyError: return redirect(loadLoginPage) + def savepostfixConfigurations(request): try: userID = request.session['userID'] @@ -1625,6 +1629,7 @@ def savepostfixConfigurations(request): except KeyError: return redirect(loadLoginPage) + def saveRedisConfigurations(request): try: userID = request.session['userID'] @@ -1661,6 +1666,7 @@ def saveRedisConfigurations(request): except KeyError: return redirect(loadLoginPage) + def saveclamavConfigurations(request): try: userID = request.session['userID'] @@ -1697,6 +1703,7 @@ def saveclamavConfigurations(request): except KeyError: return redirect(loadLoginPage) + def unistallRspamd(request): try: logging.CyberCPLogFileWriter.writeToFile("unistallRspamd...1") @@ -1708,14 +1715,12 @@ def unistallRspamd(request): else: return ACLManager.loadErrorJson() - try: execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = execPath + " uninstallRspamd" ProcessUtilities.popenExecutioner(execPath) - final_json = json.dumps({'status': 1, 'error_message': "None"}) return HttpResponse(final_json) except BaseException as msg: @@ -1732,6 +1737,7 @@ def unistallRspamd(request): return HttpResponse(final_json) + def uninstallStatusRspamd(request): try: userID = request.session['userID'] @@ -1789,6 +1795,7 @@ def uninstallStatusRspamd(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def FetchRspamdLog(request): try: userID = request.session['userID'] @@ -1837,7 +1844,7 @@ def RestartRspamd(request): ProcessUtilities.executioner(command) - dic = {'status': 1, 'error_message': 'None',} + dic = {'status': 1, 'error_message': 'None', } json_data = json.dumps(dic) return HttpResponse(json_data) except BaseException as msg: @@ -1880,6 +1887,36 @@ def EmailDebugger(request): else: return redirect("https://cyberpanel.net/cyberpanel-addons") + +def EmailDebuggerV2(request): + url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission" + data = { + "name": "email-debugger", + "IP": ACLManager.GetServerIP() + } + + import requests + response = requests.post(url, data=json.dumps(data)) + Status = response.json()['status'] + + if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + currentACL = ACLManager.loadedACL(userID) + websitesName = ACLManager.findAllSites(currentACL, userID) + + proc = httpProc(request, 'emailPremium/EmailDebuggerV2.html', + {'websiteList': websitesName}, 'admin') + return proc.render() + else: + return redirect("https://cyberpanel.net/cyberpanel-addons") + + def RunServerLevelEmailChecks(request): try: userID = request.session['userID'] @@ -1926,6 +1963,7 @@ def ResetEmailConfigurations(request): json_data = json.dumps(dic) return HttpResponse(json_data) + def statusFunc(request): try: userID = request.session['userID'] @@ -1949,6 +1987,7 @@ def statusFunc(request): json_data = json.dumps(dic) return HttpResponse(json_data) + def ReadReport(request): try: userID = request.session['userID'] @@ -1964,7 +2003,7 @@ def ReadReport(request): res = ob.ReadReport() Result = json.loads(res.content) status = Result['status'] - #fetch Ip + # fetch Ip IP = ACLManager.GetServerIP() if status == 1: def CheckPort(port): @@ -2024,7 +2063,7 @@ def ReadReport(request): final_json = json.dumps(finalResult) return HttpResponse(final_json) else: - return 0 , Result + return 0, Result except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile("Result....3:" + str(msg)) else: @@ -2034,6 +2073,7 @@ def ReadReport(request): except KeyError: return redirect(loadLoginPage) + def debugEmailForSite(request): try: userID = request.session['userID'] @@ -2054,6 +2094,7 @@ def debugEmailForSite(request): except KeyError: return redirect(loadLoginPage) + def fixMailSSL(request): try: userID = request.session['userID'] diff --git a/filemanager/static/filemanager/js/fileManagerV2.js b/filemanager/static/filemanager/js/fileManagerV2.js new file mode 100644 index 000000000..1519fcd82 --- /dev/null +++ b/filemanager/static/filemanager/js/fileManagerV2.js @@ -0,0 +1,1819 @@ +newapp.controller('fileManagerCtrlV2', function ($scope, $http, FileUploader, $window) { + + alert('Error'); + $('form').submit(function (e) { + e.preventDefault(); + }); + + $(document.body).click(function () { + rightClickNode.style.display = "none"; + }); + + var editor = ace.edit("htmlEditorContent"); + var aceEditorMode = ''; + + var domainName = $("#domainNameInitial").text(); + var domainRandomSeed = ""; + + $scope.currentRPath = "/"; + var homeRPathBack = "/"; + + + var homePathBack = "/home/" + domainName; + $scope.currentPath = "/home/" + domainName; + $scope.startingPath = domainName; + $scope.completeStartingPath = "/home/" + domainName; + var trashPath = homePathBack + '/.trash' + + $scope.editDisable = true; + // disable loading image on tree loading + $scope.treeLoading = true; + // html editor + $scope.errorMessageEditor = true; + $scope.htmlEditorLoading = true; + $scope.saveSuccess = true; + var allFilesAndFolders = []; + + $scope.showUploadBox = function () { + $('#uploadBox').modal('show'); + }; + + $scope.showHTMLEditorModal = function (MainFM = 0) { + $scope.htmlEditorLoading = false; + $scope.errorMessageEditor = true; + $('#showHTMLEditor').modal('show'); + $scope.fileInEditor = allFilesAndFolders[0]; + $scope.getFileContents(MainFM); + }; + + + // tree + + $scope.fetchChilds = function (element, completePath, functionName) { + + // start loading tree + $scope.treeLoading = false; + + var funcCompletePath = ""; + var nodeForChilds = ""; + + if (functionName === "primary") { + nodeForChilds = element.currentTarget.parentNode; + funcCompletePath = completePath; + } else { + nodeForChilds = element.parentNode; + funcCompletePath = completePath; + } + url = '/filemanager/controller'; + + + var data = { + completeStartingPath: completePath, + method: "list", + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + $scope.treeLoading = true; + + + if (response.data.status === 1) { + + /// node prepration + + var ulNode = prepareChildNodeUL(); + nodeForChilds.appendChild(ulNode); + + var filesData = response.data; + + var keys = Object.keys(filesData); + + for (var i = 0; i < keys.length; i++) { + if (keys[i] === "error_message" | keys[i] === "status") { + continue; + } else { + path = filesData[keys[i]][0]; + completePath = filesData[keys[i]][1]; + dropDown = filesData[keys[i]][2]; + finalPrepration(ulNode, path, completePath, dropDown); + } + } + + activateMinus(nodeForChilds, funcCompletePath); + } else { + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + function finalPrepration(parentNode, path, completePath, dropDown) { + parentNode.appendChild(prepareChildNodeLI(path, completePath, dropDown)); + } + + function prepareChildNodeLI(path, completePath, dropDown) { + + // text nodes are created + var spaceNode = document.createTextNode(" "); + var pathNode = document.createTextNode(" " + path); + + // + + var attachFunc = function () { + $scope.fetchChilds(aNode, completePath, "secondary"); + }; + + var aNode = document.createElement('a'); + aNode.setAttribute('href', '#'); + aNode.addEventListener("click", attachFunc); + aNode.setAttribute('onclick', 'return false;'); + + var secondANode = document.createElement('a'); + secondANode.setAttribute('href', '#'); + secondANode.setAttribute('onclick', 'return false;'); + + // + + var iNodePlus = document.createElement('i'); + iNodePlus.setAttribute('class', 'fa fa-plus'); + iNodePlus.setAttribute('aria-hidden', 'true'); + iNodePlus.style.color = "#007bff"; + + var iNodeFolder = document.createElement('i'); + iNodeFolder.setAttribute('class', 'fa fa-folder'); + iNodeFolder.setAttribute('aria-hidden', 'true'); + + var iNodeFile = document.createElement('i'); + iNodeFile.setAttribute('class', 'fa fa-file'); + iNodeFile.setAttribute('aria-hidden', 'true'); + iNodeFile.style.color = "#007bff"; + + // + + var liNode = document.createElement('li'); + liNode.setAttribute('class', 'list-group-item'); + liNode.style.border = "None"; + + // node preparation + + if (dropDown == true) { + secondANode.appendChild(iNodeFolder); + secondANode.appendChild(pathNode); + secondANode.addEventListener("click", function () { + $scope.fetchForTableSecondary(secondANode, "fromTree", completePath); + }); + + // This makes completion of {{ startingPath }} + + + aNode.appendChild(spaceNode); + aNode.appendChild(iNodePlus); + aNode.appendChild(spaceNode); + + // + + liNode.appendChild(aNode); + liNode.appendChild(secondANode); + + return liNode; + } else { + liNode.appendChild(iNodeFile); + liNode.appendChild(pathNode); + return liNode; + + } + } + + function prepareChildNodeUL() { + + // text nodes are created + var ulNode = document.createElement('ul'); + ulNode.setAttribute('class', 'list-group list-group-flush'); + return ulNode; + } + + function activateMinus(node, completePath) { + + var collectionOfA = node.getElementsByTagName("a"); + + // + + var aNode = document.createElement('a'); + aNode.setAttribute('href', '#'); + aNode.addEventListener("click", function () { + deleteChilds(aNode, completePath); + }); + aNode.setAttribute('onclick', 'return false;'); + + // + + var spaceNode = document.createTextNode(" "); + + var iNodeMinus = document.createElement('i'); + iNodeMinus.setAttribute('class', 'fa fa-minus'); + iNodeMinus.setAttribute('aria-hidden', 'true'); + iNodeMinus.style.color = "#007bff"; + + // prepare node + + aNode.appendChild(iNodeMinus); + aNode.appendChild(spaceNode); + + node.insertBefore(aNode, collectionOfA[1]); + node.removeChild(collectionOfA[0]); + + } + + function deleteChilds(aNode, completePath) { + + parent = aNode.parentNode; + + var collectionOfUL = parent.getElementsByTagName("ul"); + parent.removeChild(collectionOfUL[0]); + + + var collectionOfA = parent.getElementsByTagName("a"); + + // + + var newANode = document.createElement('a'); + newANode.setAttribute('href', '#'); + newANode.addEventListener("click", function () { + $scope.fetchChilds(newANode, completePath, "secondary"); + }); + newANode.setAttribute('onclick', 'return false;'); + + // + + var spaceNode = document.createTextNode(" "); + + var iNodePlus = document.createElement('i'); + iNodePlus.setAttribute('class', 'fa fa-plus'); + iNodePlus.setAttribute('aria-hidden', 'true'); + iNodePlus.style.color = "#007bff"; + + // prepare node + + newANode.appendChild(iNodePlus); + newANode.appendChild(spaceNode); + + parent.insertBefore(newANode, collectionOfA[1]); + parent.removeChild(collectionOfA[0]); + + + } + + // tree ends + + + $scope.selectAll = function () { + + var tableBody = document.getElementById("tableBodyFiles"); + var getFileName = tableBody.firstChild.firstChild.innerHTML; + allFilesAndFolders = []; + + var collectionOfA = tableBody.getElementsByTagName("tr"); + + for (var i = 0; i < collectionOfA.length; i++) { + collectionOfA[i].style.background = "#ccdbe8"; + var getFileName = collectionOfA[i].getElementsByTagName('td')[0].innerHTML; + allFilesAndFolders.push(getFileName); + } + + $scope.buttonActivator(); + + }; + $scope.unSelectAll = function () { + + var tableBody = document.getElementById("tableBodyFiles"); + var getFileName = tableBody.firstChild.firstChild.innerHTML; + allFilesAndFolders = []; + + var collectionOfA = tableBody.getElementsByTagName("tr"); + + for (var i = 0; i < collectionOfA.length; i++) { + collectionOfA[i].style.background = "None"; + } + + $scope.buttonActivator(); + }; + + function addFileOrFolderToList(nodeName) { + + var rightClickNode = document.getElementById("rightClick") + + var check = 1; + var getFileName = nodeName.getElementsByTagName('td')[0].innerHTML; + + if (nodeName.style.backgroundColor === "rgb(204, 219, 232)") { + + var tempArray = []; + nodeName.style.background = "None"; + + for (var j = 0; j < allFilesAndFolders.length; j++) { + if (allFilesAndFolders[j] != getFileName) { + tempArray.push(allFilesAndFolders[j]); + } + } + allFilesAndFolders = tempArray; + // activating deactivating functions + $scope.buttonActivator(); + return; + } + + nodeName.style.background = "#ccdbe8"; + + + for (var j = 0; j < allFilesAndFolders.length; j++) { + if (allFilesAndFolders[j] === getFileName) { + check = 0; + break; + } + } + if (check === 1) { + allFilesAndFolders.push(getFileName); + } + + // activating deactivating functions + $scope.buttonActivator(); + + + } + + function createTR(fileName, fileSize, lastModified, permissions, dirCheck) { + + // text nodes are created + var fileNameNode = document.createTextNode(fileName); + var fileSizeNode = document.createTextNode(fileSize); + var lastModifiedNode = document.createTextNode(lastModified); + var permissionsNode = document.createTextNode(permissions); + + // + + var iNodeFolder = document.createElement('i'); + iNodeFolder.setAttribute('class', 'fa fa-folder'); + iNodeFolder.setAttribute('aria-hidden', 'true'); + iNodeFolder.style.color = "#007bff"; + + var iNodeFile = document.createElement('i'); + iNodeFile.setAttribute('class', 'fa fa-file'); + iNodeFile.setAttribute('aria-hidden', 'true'); + iNodeFile.style.color = "#007bff"; + + // + + var firstTDNode = document.createElement('td'); + var secondTDNode = document.createElement('td'); + var thirdTDNode = document.createElement('td'); + var forthTDNode = document.createElement('td'); + var fifthTDNode = document.createElement('td'); + + fifthTDNode.style.display = "none"; + + // + + + var thNode = document.createElement('th'); + thNode.setAttribute('scope', 'row'); + + // + + var trNode = document.createElement('tr'); + + // node preparation + + firstTDNode.appendChild(fileNameNode); + secondTDNode.appendChild(fileSizeNode); + thirdTDNode.appendChild(lastModifiedNode); + forthTDNode.appendChild(permissionsNode); + + if (dirCheck == true) { + thNode.appendChild(iNodeFolder); + trNode.appendChild(thNode); + trNode.addEventListener("dblclick", function () { + $scope.fetchForTableSecondary(firstTDNode, "doubleClick"); + }); + trNode.addEventListener("click", function () { + addFileOrFolderToList(trNode); + }); + trNode.addEventListener("contextmenu", function (event) { + $scope.rightClickCallBack(event, trNode); + }); + + // Hidden td to represent file or folder + + var fileOrFolderNode = document.createTextNode("Folder"); + fifthTDNode.appendChild(fileOrFolderNode) + } else { + thNode.appendChild(iNodeFile); + trNode.appendChild(thNode); + trNode.addEventListener("click", function () { + addFileOrFolderToList(trNode); + }); + trNode.addEventListener("contextmenu", function (event) { + $scope.rightClickCallBack(event, trNode); + }); + + // Hidden td to represent file or folder + + var fileOrFolderNode = document.createTextNode("File"); + fifthTDNode.appendChild(fileOrFolderNode) + } + + trNode.appendChild(firstTDNode); + trNode.appendChild(secondTDNode); + trNode.appendChild(thirdTDNode); + trNode.appendChild(forthTDNode); + trNode.appendChild(fifthTDNode); + + return trNode; + + } + + + // Button Activator + + $scope.buttonActivator = function () { + + // for restore button + if ($scope.currentPath === trashPath) { + var restoreBTN = document.getElementById("restoreRight"); + restoreBTN.style.display = "block"; + } else { + var restoreBTN = document.getElementById("restoreRight"); + restoreBTN.style.display = "none"; + } + // for edit button + + if (allFilesAndFolders.length === 1) { + var editNode = document.getElementById("editFile"); + editNode.style.pointerEvents = "auto"; + + var editNotRight = document.getElementById("editOnRight"); + + var result = findFileExtension(allFilesAndFolders[0]); + + if (result !== undefined) { + if (result[0] === "js") { + aceEditorMode = "ace/mode/javascript"; + editNotRight.style.display = "Block"; + } else if (result[0] === "html") { + aceEditorMode = "ace/mode/html"; + editNotRight.style.display = "Block"; + } else if (result[0] === "css") { + aceEditorMode = "ace/mode/css"; + editNotRight.style.display = "Block"; + } else if (result[0] === "php") { + aceEditorMode = "ace/mode/php"; + editNotRight.style.display = "Block"; + } else if (result[0] === "py") { + aceEditorMode = "ace/mode/python"; + editNotRight.style.display = "Block"; + } else if (result[0] === "txt") { + aceEditorMode = ""; + editNotRight.style.display = "Block"; + } else if (result[0] === "htaccess") { + aceEditorMode = ""; + editNotRight.style.display = "Block"; + } else { + var editNode = document.getElementById("editFile"); + editNode.style.pointerEvents = "none"; + editNotRight.style.display = "None"; + } + } else { + var editNode = document.getElementById("editFile"); + editNode.style.pointerEvents = "none"; + editNotRight.style.display = "None"; + } + } else { + var editNode = document.getElementById("editFile"); + editNode.style.pointerEvents = "none"; + } + + // extraction button + + if (allFilesAndFolders.length === 1) { + var extractFileNode = document.getElementById("extractFile"); + extractFileNode.style.pointerEvents = "auto"; + + var extractNodeRight = document.getElementById("extractOnRight"); + + var result = findFileExtension(allFilesAndFolders[0]); + + if (result !== undefined) { + if (result[0] === "gz") { + extractFileNode.style.pointerEvents = "auto"; + extractNodeRight.style.display = "Block"; + } else if (result[0] === "zip") { + extractFileNode.style.pointerEvents = "auto"; + extractNodeRight.style.display = "Block"; + } else { + extractFileNode.style.pointerEvents = "none"; + extractNodeRight.style.display = "None"; + } + } else { + extractFileNode.style.pointerEvents = "none"; + extractNodeRight.style.display = "None"; + } + } else { + var extractFileNode = document.getElementById("extractFile"); + extractFileNode.style.pointerEvents = "none"; + } + + + // move button + + if (allFilesAndFolders.length >= 1) { + + var moveFileNode = document.getElementById("moveFile"); + moveFileNode.style.pointerEvents = "auto"; + } else { + var moveFileNode = document.getElementById("moveFile"); + moveFileNode.style.pointerEvents = "none"; + } + + //copy button + + if (allFilesAndFolders.length >= 1) { + + var copeFileNode = document.getElementById("copyFile"); + copeFileNode.style.pointerEvents = "auto"; + } else { + var copeFileNode = document.getElementById("copyFile"); + copeFileNode.style.pointerEvents = "none"; + } + + + // rename button + + if (allFilesAndFolders.length === 1) { + + var renameFileNode = document.getElementById("renameFile"); + renameFileNode.style.pointerEvents = "auto"; + } else { + var renameFileNode = document.getElementById("renameFile"); + renameFileNode.style.pointerEvents = "none"; + } + + + // compress button + + if (allFilesAndFolders.length >= 1) { + var compressFile = document.getElementById("compressFile"); + compressFile.style.pointerEvents = "auto"; + } else { + var compressFile = document.getElementById("compressFile"); + compressFile.style.pointerEvents = "none"; + } + + + // move button + + if (allFilesAndFolders.length >= 1) { + + var deleteFile = document.getElementById("deleteFile"); + deleteFile.style.pointerEvents = "auto"; + } else { + var deleteFile = document.getElementById("deleteFile"); + deleteFile.style.pointerEvents = "none"; + } + + + }; + $scope.buttonActivator(); + + // table functions + + + $scope.fetchForTableSecondary = function (node, functionName) { + + allFilesAndFolders = []; + $scope.buttonActivator(); + url = "/filemanager/controller"; + var completePathToFile = ""; + + if (domainName === "") { + + if (functionName === "startPoint") { + completePathToFile = $scope.currentRPath; + } else if (functionName === "doubleClick") { + 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; + // check if there is any path in QS + + const urlParams = new URLSearchParams(window.location.search); + QSPath = urlParams.get('path') + + if (QSPath !== null) { + completePathToFile = QSPath + } + + // + } 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; + } + + + var data = { + completeStartingPath: completePathToFile, + method: "listForTable", + home: "/", + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + var tableBody = document.getElementById("tableBodyFiles"); + var loadingPath = "/static/filemanager/images/loading.gif"; + tableBody.innerHTML = ''; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + tableBody.innerHTML = ''; + + + if (response.data.status === 1) { + + + /// node prepration + + var filesData = response.data; + + var keys = Object.keys(filesData); + + for (var i = 0; i < keys.length; i++) { + if (keys[i] === "error_message" | keys[i] === "status") { + continue; + } else { + var fileName = filesData[keys[i]][0]; + var lastModified = filesData[keys[i]][2]; + var fileSize = filesData[keys[i]][3]; + var permissions = filesData[keys[i]][4]; + var dirCheck = filesData[keys[i]][5]; + // console.log(fileName); + if (fileName === "..filemanagerkey") { + + continue; + } + tableBody.appendChild(createTR(fileName, fileSize, lastModified, permissions, dirCheck)); + + } + } + } else { + var notification = alertify.notify(response.data.error_message, 'error', 10, function () { + }); + $scope.fetchForTableSecondary(null, 'homeFetch'); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + function findFileExtension(fileName) { + return (/[.]/.exec(fileName)) ? /[^.]+$/.exec(fileName) : undefined; + } + + $scope.fetchForTableSecondary(null, "startPoint"); + + // html editor + + $scope.getFileContents = function (MainFM = 0) { + + + // console.log("selectedfile"+ allFilesAndFolders) + // console.log("currentpath"+ $scope.currentRPath) + if (MainFM === 1) { + var completePathForFile = $scope.currentPath + "/" + allFilesAndFolders[0]; + } else { + var completePathForFile = $scope.currentRPath + "/" + allFilesAndFolders[0]; + } + + var data = { + fileName: completePathForFile, + method: "readFileContents", + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.htmlEditorLoading = true; + + if (response.data.status === 1) { + + var editor = ace.edit("htmlEditorContent"); + editor.setTheme("ace/theme/chrome"); + editor.getSession().setMode(aceEditorMode); + editor.setValue(response.data.fileContents); + + } else { + $scope.errorMessageEditor = false; + $scope.error_message = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + $scope.putFileContents = function () { + + $scope.htmlEditorLoading = false; + $scope.saveSuccess = true; + $scope.errorMessageEditor = true; + + var completePathForFile = $scope.currentPath + "/" + allFilesAndFolders[0]; + + var data = { + fileName: completePathForFile, + method: "writeFileContents", + fileContent: editor.getValue(), + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + $scope.htmlEditorLoading = true; + + if (response.data.status === 1) { + $scope.htmlEditorLoading = true; + $scope.saveSuccess = false; + } else { + $scope.errorMessageEditor = false; + $scope.error_message = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + /// code mirror open + + $scope.editWithCodeMirror = function () { + var completePathForFile = $scope.currentPath + "/" + allFilesAndFolders[0]; + var finalURL = 'https://' + window.location.hostname + ':' + window.location.port + '/filemanager/editFile?domainName=' + domainName + '&fileName=' + completePathForFile; + window.open(finalURL); + }; + + + // uploads + + $scope.errorMessage = true; + var uploader; + if (domainName === "") { + uploader = $scope.uploader = new FileUploader({ + url: "/filemanager/upload", + headers: { + 'X-CSRFToken': getCookie('csrftoken') // X-CSRF-TOKEN is used for Ruby on Rails Tokens + }, + formData: [{ + "method": "upload", + "home": homeRPathBack + }] + }); + } else { + uploader = $scope.uploader = new FileUploader({ + url: "/filemanager/upload", + headers: { + 'X-CSRFToken': getCookie('csrftoken') // X-CSRF-TOKEN is used for Ruby on Rails Tokens + }, + formData: [{ + "method": "upload", + "home": homePathBack + }] + }); + } + + + uploader.onCompleteItem = function (fileItem, response, status, headers) { + if (response.uploadStatus === 1) { + $scope.errorMessage = true; + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + $scope.errorMessage = false; + $scope.fileName = response.fileName; + $scope.error_message = response.error_message; + } + }; + + uploader.onAfterAddingFile = function (fileItem) { + var basepath; + if (domainName == "") { + basepath = $scope.currentRPath; + } else { + basepath = $scope.currentPath + } + $scope.errorMessage = true; + fileItem.formData.push( + { + "completePath": basepath, + domainRandomSeed: domainRandomSeed, + domainName: domainName + + }); + }; + + // folder functions + + $scope.createSuccess = true; + $scope.errorMessageFolder = true; + + // + $scope.showCreateFolderModal = function () { + $scope.createSuccess = true; + $scope.errorMessageFolder = true; + $scope.newFolderName = ""; + $('#showCreateFolder').modal('show'); + }; + + $scope.createFolderEnter = function ($event) { + var keyCode = $event.which || $event.keyCode; + if (keyCode === 13) { + $scope.htmlEditorLoading = false; + $scope.createNewFolder(); + } + }; + + $scope.createNewFolder = function () { + + var completePathForFolder; + if (domainName === "") { + completePathForFolder = $scope.currentRPath + "/" + $scope.newFolderName; + $scope.errorMessageFile = true; + } else { + completePathForFolder = $scope.currentPath + "/" + $scope.newFolderName; + $scope.errorMessageFile = true; + } + + if ($scope.newFolderName.length === 0) { + $scope.errorMessageFolder = false; + $scope.error_message = "Please enter folder name!"; + return; + } + + + var data = { + folderName: completePathForFolder, + method: "createNewFolder", + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + var url = '/filemanager/controller'; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.createSuccess = false; + $scope.fetchForTableSecondary(null, 'refresh'); + $('#showCreateFolder').modal('hide'); + } else { + $scope.errorMessageFolder = false; + $scope.error_message = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + // + + $scope.createSuccess = true; + $scope.errorMessageFile = true; + + $scope.showCreateFileModal = function () { + $scope.createSuccess = true; + $scope.errorMessageFile = true; + $scope.newFileName = ""; + $('#showCreateFile').modal('show'); + }; + + $scope.createFileEnter = function ($event) { + var keyCode = $event.which || $event.keyCode; + if (keyCode === 13) { + $scope.htmlEditorLoading = false; + $scope.createNewFile(); + } + + }; + + $scope.createNewFile = function () { + var completePathForFile; + if (domainName === "") { + completePathForFile = $scope.currentRPath + "/" + $scope.newFileName; + $scope.errorMessageFile = true; + } else { + completePathForFile = $scope.currentPath + "/" + $scope.newFileName; + $scope.errorMessageFile = true; + } + + + if ($scope.newFileName.length === 0) { + $scope.errorMessageFile = false; + $scope.error_message = "Please enter file name!"; + return; + } + + var data = { + fileName: completePathForFile, + method: "createNewFile", + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.createSuccess = false; + $scope.fetchForTableSecondary(null, 'refresh'); + $('#showCreateFile').modal('hide'); + } else { + $scope.errorMessageFile = false; + $scope.error_message = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + $scope.createSuccess = true; + $scope.errorMessageFile = true; + + // + + $scope.deleteLoading = true; + + $scope.showDeleteModal = function () { + $('#showDelete').modal('show'); + }; + + $scope.deleteFolderOrFile = function () { + var pth; + var trash; + if (domainName === "") { + pth = $scope.currentRPath; + trash = true; + + } else { + pth = $scope.currentPath; + trash = $scope.skipTrash + } + + $scope.deleteLoading = false; + + var data = { + path: pth, + method: "deleteFolderOrFile", + fileAndFolders: allFilesAndFolders, + domainRandomSeed: domainRandomSeed, + domainName: domainName, + skipTrash: trash + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.deleteLoading = true; + if (response.data.status === 1) { + $('#showDelete').modal('hide'); + var notification = alertify.notify('Successfully Deleted!', 'success', 5, function () { + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + var notification = alertify.notify('Files/Folders can not be deleted', 'error', 5, function () { + console.log('dismissed'); + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + + // Compression + + $scope.compressionLoading = true; + + $scope.showCompressionModal = function () { + $('#showCompression').modal('show'); + + $scope.listOfFiles = ""; + $scope.compressedFileName = ""; + + for (var i = 0; i < allFilesAndFolders.length; i++) { + $scope.listOfFiles = $scope.listOfFiles + allFilesAndFolders[i] + "\n"; + } + }; + + $scope.startCompression = function () { + var basepathh; + if (domainName === "") { + basepathh = $scope.currentRPath; + } else { + basepathh = $scope.currentPath; + } + + + $scope.compressionLoading = false; + + var data = { + home: homePathBack, + basePath: basepathh, + listOfFiles: allFilesAndFolders, + compressedFileName: $scope.compressedFileName, + compressionType: $scope.compressionType, + method: 'compress', + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + $scope.compressionLoading = true; + $('#showCompression').modal('hide'); + if (response.data.status === 1) { + var notification = alertify.notify('Successfully Compressed!', 'success', 5, function () { + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + var notification = alertify.notify(response.data.error_message, 'error', 5, function () { + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + // extraction + + $scope.extractionLoading = true; + + $scope.showExtractionModal = function () { + $scope.extractionLocation = $scope.currentPath; + $('#showExtraction').modal('show'); + $scope.fileToBeExtracted = allFilesAndFolders[0]; + }; + + $scope.startExtraction = function () { + + var pathbase; + if (domainName === "") { + pathbase = $scope.currentRPath; + } else { + pathbase = $scope.currentPath; + } + + + $scope.extractionLoading = false; + + var completeFileToExtract = pathbase + "/" + allFilesAndFolders[0]; + var extractionType = ""; + + if (findFileExtension(completeFileToExtract) == "gz") { + extractionType = "tar.gz"; + } else { + extractionType = "zip"; + } + + var data = { + home: homePathBack, + basePath: pathbase, + fileToExtract: completeFileToExtract, + extractionType: extractionType, + extractionLocation: $scope.extractionLocation, + method: 'extract', + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + $scope.extractionLoading = true; + $('#showExtraction').modal('hide'); + + if (response.data.status === 1) { + var notification = alertify.notify('Successfully Extracted!', 'success', 5, function () { + console.log('dismissed'); + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + var notification = alertify.notify(response.data.error_message, 'error', 10, function () { + console.log('dismissed'); + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + /// move + + $scope.moveLoading = true; + + $scope.showMoveModal = function () { + $('#showMove').modal('show'); + $scope.pathToMoveTo = $scope.currentPath; + + $scope.listOfFiles = ""; + + for (var i = 0; i < allFilesAndFolders.length; i++) { + $scope.listOfFiles = $scope.listOfFiles + allFilesAndFolders[i] + "\n"; + } + + } + + $scope.startMoving = function () { + + var basepth; + if (domainName == "") { + basepth = $scope.currentRPath; + } else { + basepth = $scope.currentPath; + } + + $scope.moveLoading = false; + + var data = { + home: homePathBack, + basePath: basepth, + newPath: $scope.pathToMoveTo, + fileAndFolders: allFilesAndFolders, + method: 'move', + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + $scope.moveLoading = true; + $('#showMove').modal('hide'); + + if (response.data.status === 1) { + var notification = alertify.notify('Successfully Moved!', 'success', 5, function () { + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + var notification = alertify.notify(response.data.error_message, 'error', 5, function () { + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + /// copy + + $scope.copyLoading = true; + + $scope.showCopyModal = function () { + $('#showCopy').modal('show'); + $scope.pathToCopyTo = $scope.currentPath; + + $scope.listOfFiles = ""; + + for (var i = 0; i < allFilesAndFolders.length; i++) { + $scope.listOfFiles = $scope.listOfFiles + allFilesAndFolders[i] + "\n"; + } + + }; + + + $scope.startCopying = function () { + var basepath; + + if (domainName == "") { + basepath = $scope.currentRPath; + } else { + basepath = $scope.currentPath; + } + + $scope.copyLoading = false; + + var data = { + home: homePathBack, + basePath: basepath, + newPath: $scope.pathToCopyTo, + fileAndFolders: allFilesAndFolders, + method: 'copy', + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.copyLoading = true; + + $('#showCopy').modal('hide'); + + if (response.data.status === 1) { + var notification = alertify.notify('Successfully Copied!', 'success', 5, function () { + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + var notification = alertify.notify(response.data.error_message, 'error', 5, function () { + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + // right click settings + + var rightClickNode = document.getElementById("rightClick"); + rightClickNode.style.display = "none"; + + $scope.rightClickCallBack = function (event, trNode) { + var rightClickNode = document.getElementById("rightClick") + rightClickNode.style.display = "block"; + + event.preventDefault(); + $scope.unSelectAll(); + + $('#rightClick').css({ + 'top': event.pageY, + 'left': event.pageX + }); + + // If we want to enable download for this node + + var downloadOnRight = document.getElementById("downloadOnRight"); + + if (trNode.lastChild.innerHTML === "File") { + downloadOnRight.style.display = "Block"; + } else { + downloadOnRight.style.display = "none"; + } + + + $scope.addFileOrFolderToListForRightClick(trNode); + }; + + $scope.addFileOrFolderToListForRightClick = function (nodeName) { + + var check = 1; + var getFileName = nodeName.getElementsByTagName('td')[0].innerHTML; + + if (nodeName.style.backgroundColor === "#ccdbe8") { + + var tempArray = []; + nodeName.style.background = "None"; + + for (var j = 0; j < allFilesAndFolders.length; j++) { + if (allFilesAndFolders[j] != getFileName) { + tempArray.push(allFilesAndFolders[j]); + } + } + allFilesAndFolders = tempArray; + // activating deactivating functions + $scope.buttonActivator(); + return; + } + + nodeName.style.background = "#ccdbe8"; + + + for (var j = 0; j < allFilesAndFolders.length; j++) { + if (allFilesAndFolders[j] === getFileName) { + check = 0; + break; + } + } + if (check === 1) { + allFilesAndFolders.push(getFileName); + } + + // activating deactivating functions + $scope.buttonActivator(); + + }; + + // rename + + + $scope.renameLoading = true; + + $scope.showRenameModal = function () { + $('#showRename').modal('show'); + $scope.fileToRename = allFilesAndFolders[0]; + $scope.newFileName = ""; + }; + + $scope.renameEnter = function ($event) { + var keyCode = $event.which || $event.keyCode; + if (keyCode === 13) { + $scope.htmlEditorLoading = false; + $scope.renameFile(); + } + }; + + $scope.renameFile = function () { + + var bpath; + if (domainName === "") { + bpath = $scope.currentRPath; + } else { + bpath = $scope.currentPath; + } + + $scope.renameLoading = false; + + var data = { + basePath: bpath, + existingName: $scope.fileToRename, + newFileName: $scope.newFileName, + method: 'rename', + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + $scope.moveLoading = true; + $('#showRename').modal('hide'); + $scope.renameLoading = true; + + if (response.data.status === 1) { + var notification = alertify.notify('Successfully Renamed!', 'success', 5, function () { + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + var notification = alertify.notify(response.data.error_message, 'error', 5, function () { + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + + // Fix permissions + + $scope.fixPermissions = function () { + + url = "/filemanager/changePermissions"; + + + var data = { + domainName: domainName, + domainRandomSeed: domainRandomSeed, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + + if (response.data.permissionsChanged === 1) { + var notification = alertify.notify('Permissions successfully fixed!', 'success', 5, function () { + console.log('dismissed'); + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + var notification = alertify.notify(response.data.error_message, 'error', 5, function () { + console.log('dismissed'); + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + // Download files + + $scope.downloadFile = function () { + url = "/filemanager/downloadFile"; + var downloadURL = $scope.currentPath + "/" + allFilesAndFolders[0]; + 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 + + $scope.changePermissionsLoading = true; + + $scope.userPermissions = 0; + $scope.groupPermissions = 0; + $scope.wordlPermissions = 0; + + $scope.showPermissionsModal = function () { + $('#showPermissions').modal('show'); + $scope.permissionsPath = allFilesAndFolders[0]; + }; + + $scope.updateReadPermissions = function (value) { + + switch (value) { + + case 'userRead': + + if ($scope.userRead === true) { + $scope.userPermissions = $scope.userPermissions + 4; + } else { + if ($scope.userRead !== undefined) { + $scope.userPermissions = $scope.userPermissions - 4; + } + } + break; + + + case 'groupRead': + if ($scope.groupRead === true) { + $scope.groupPermissions = $scope.groupPermissions + 4; + } else { + if ($scope.groupRead !== undefined) { + $scope.groupPermissions = $scope.groupPermissions - 4; + } + } + break; + + + case 'worldRead': + if ($scope.worldRead === true) { + $scope.wordlPermissions = $scope.wordlPermissions + 4; + } else { + if ($scope.worldRead !== undefined) { + $scope.wordlPermissions = $scope.wordlPermissions - 4; + } + } + break; + } + }; + + $scope.updateWritePermissions = function (value) { + + switch (value) { + + case 'userWrite': + + if ($scope.userWrite === true) { + $scope.userPermissions = $scope.userPermissions + 2; + } else { + if ($scope.userWrite !== undefined) { + $scope.userPermissions = $scope.userPermissions - 2; + } + } + break; + + + case 'groupWrite': + if ($scope.groupWrite === true) { + $scope.groupPermissions = $scope.groupPermissions + 2; + } else { + if ($scope.groupWrite !== undefined) { + $scope.groupPermissions = $scope.groupPermissions - 2; + } + } + break; + + + case 'worldWrite': + if ($scope.worldWrite === true) { + $scope.wordlPermissions = $scope.wordlPermissions + 2; + } else { + if ($scope.worldWrite !== undefined) { + $scope.wordlPermissions = $scope.wordlPermissions - 2; + } + } + break; + } + }; + + $scope.updateExecutePermissions = function (value) { + + switch (value) { + + case 'userExecute': + + if ($scope.userExecute === true) { + $scope.userPermissions = $scope.userPermissions + 1; + } else { + if ($scope.userExecute !== undefined) { + $scope.userPermissions = $scope.userPermissions - 1; + } + } + break; + + + case 'groupExecute': + if ($scope.groupExecute === true) { + $scope.groupPermissions = $scope.groupPermissions + 1; + } else { + if ($scope.groupExecute !== undefined) { + $scope.groupPermissions = $scope.groupPermissions - 1; + } + } + break; + + + case 'worldExecute': + if ($scope.worldExecute === true) { + $scope.wordlPermissions = $scope.wordlPermissions + 1; + } else { + if ($scope.worldExecute !== undefined) { + $scope.wordlPermissions = $scope.wordlPermissions - 1; + } + } + break; + } + }; + + $scope.changePermissionsRecursively = function () { + $scope.changePermissions(1); + }; + + + $scope.changePermissions = function (recursive) { + + $scope.changePermissionsLoading = false; + var newPermissions = String($scope.userPermissions) + String($scope.groupPermissions) + String($scope.wordlPermissions); + + var data = { + basePath: $scope.currentPath, + permissionsPath: $scope.permissionsPath, + method: 'changePermissions', + domainRandomSeed: domainRandomSeed, + recursive: recursive, + newPermissions: newPermissions, + domainName: domainName + }; + + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + $scope.changePermissionsLoading = true; + $('#showPermissions').modal('hide'); + + if (response.data.status === 1) { + var notification = alertify.notify('Permissions Successfully Changed!', 'success', 5, function () { + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + var notification = alertify.notify(response.data.error_message, 'error', 5, function () { + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + /// + + // + $scope.cyberPanelLoading = true; + $scope.showRestoreModal = function () { + $scope.createSuccess = true; + $scope.errorMessageFolder = true; + $scope.newFolderName = ""; + $('#showRestore').modal('show'); + }; + + $scope.restoreFinal = function () { + $scope.cyberPanelLoading = false; + var data = { + path: $scope.currentPath, + method: "restore", + fileAndFolders: allFilesAndFolders, + domainRandomSeed: domainRandomSeed, + domainName: domainName, + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + $('#showRestore').modal('hide'); + var notification = alertify.notify('Successfully restored to its original location!', 'success', 5, function () { + }); + $scope.fetchForTableSecondary(null, 'refresh'); + } else { + var notification = alertify.notify('Files/Folders can not be restored', 'error', 5, function () { + console.log('dismissed'); + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + +}); \ No newline at end of file diff --git a/filemanager/templates/filemanager/indexv2.html b/filemanager/templates/filemanager/indexv2.html index d2e2e89cd..d990f9077 100644 --- a/filemanager/templates/filemanager/indexv2.html +++ b/filemanager/templates/filemanager/indexv2.html @@ -1 +1,426 @@ -

    habbi test

    \ No newline at end of file +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + +{# #} +{# {% trans "File Manager - CyberPanel" %}#} +{# #} +{# #} +{# #} +{##} +{# {% load static %}#} +{# #} +{##} +{# #} +{##} +{##} +{# #} +{# #} +{# #} +{# #} +{# #} +{##} +{# #} +{# #} +{##} +{##} +{# #} +{##} +{# #} + +
    +
    +
    +

    Current Path

    +
    +
    + +
    +
    + +
    +
    +
    +
    +
      +
    • + {% trans "Upload" %} + +
    • +
    • + {% trans "New File" %} + + +
    • +
    • + {% trans "New Folder" %} + + +
    • +
    • + {% trans "Delete" %} +
    • +
    • + {% trans "Copy" %} +
    • +
    • + {% trans "Move" %} +
    • +
    • + {% trans "Rename" %} +
    • +
    • + {% trans "Edit" %} +
    • +
    • + {% trans "Compress" %} +
    • +
    • + {% trans "Extract" %} +
    • +
    +
    + +
    +
    + + + + + + + + + + + +
    + File Name + + Size (KB) + + Last Modified + + Permissions +
    +
    +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/mailServer/templates/mailServer/listEmailsV2.html b/mailServer/templates/mailServer/listEmailsV2.html index f606ca4bb..0d8d6f216 100644 --- a/mailServer/templates/mailServer/listEmailsV2.html +++ b/mailServer/templates/mailServer/listEmailsV2.html @@ -74,154 +74,7 @@

    Details To Configure Mail Clients

    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    - POP3 - - Details -
    - Server Hostname - - {$ serverHostname $} -
    - Port - - 110 -
    - Port - - 995 (SSL) -
    - SSL - - STARTTLS -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    - IMAP - - Details -
    - Server Hostname - - {$ serverHostname $} -
    - Port - - 143 -
    - Port - - 993 (SSL) -
    - SSL - - STARTTLS -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    - SMTP - - Details -
    - Server Hostname - - {$ serverHostname $} -
    - Port - - 25 -
    - Port - - 587 (SSL) -
    - 465 (SSL) - - STARTTLS -
    -
    - -
    +
    @@ -258,6 +111,125 @@
    +
    +
    + +
    +

    POP3

    +
    + + + + + + + + + + + + + + + + +
    + Server Hostname + + Port + + Port + + SSL +
    + {$ serverHostname $} + + 110 + + 995 (SSL) + + STARTTLS +
    +
    +
    + +
    +

    IMAP

    +
    + + + + + + + + + + + + + + + + +
    + Server Hostname + + Port + + Port + + SSL +
    + {$ serverHostname $} + + 143 + + 993 (SSL) + + STARTTLS +
    +
    +
    + +
    +

    SMTP

    +
    + + + + + + + + + + + + + + + + +
    + Server Hostname + + Port + + Port + + 465 SSL +
    + {$ serverHostname $} + + 25 + + 587 (SSL) + + STARTTLS +
    +
    +
    {% endif %}
    diff --git a/packages/templates/packages/listPackagesV2.html b/packages/templates/packages/listPackagesV2.html index 583daa2ad..0daf6b6f2 100644 --- a/packages/templates/packages/listPackagesV2.html +++ b/packages/templates/packages/listPackagesV2.html @@ -144,7 +144,8 @@ - + diff --git a/websiteFunctions/templates/websiteFunctions/installWordPressV2.html b/websiteFunctions/templates/websiteFunctions/installWordPressV2.html index c007c3c06..8daec7aaa 100644 --- a/websiteFunctions/templates/websiteFunctions/installWordPressV2.html +++ b/websiteFunctions/templates/websiteFunctions/installWordPressV2.html @@ -10,7 +10,7 @@

    Install WordPress

    Install WordPress with LSCache.

    -
    a +

    {{ domainName }} - {% trans "Installation Details" %} -

    -
    +