From 7afb36764ebf918f85016a90c79f8651a736d18f Mon Sep 17 00:00:00 2001 From: Zarak Khan Date: Thu, 25 Apr 2024 11:47:31 +0500 Subject: [PATCH] ServerStatus --- .../baseTemplate/FileManagerTRY.html | 167 ++ .../templates/baseTemplate/FileManagerV2.html | 836 +++++- .../templates/baseTemplate/newBase.html | 61 +- dockerManager/container.py | 248 +- .../static/dockerManager/dockerManagerV2.js | 1055 ++++++++ .../templates/dockerManager/imagesV2.html | 67 + .../dockerManager/listContainersV2.html | 219 ++ .../dockerManager/manageImagesV2.html | 209 ++ .../dockerManager/runContainerV2.html | 209 ++ .../dockerManager/viewContainerV2.html | 438 ++++ dockerManager/urls.py | 9 +- dockerManager/views.py | 228 +- filemanager/urls.py | 12 +- filemanager/views.py | 49 + firewall/firewallManager.py | 268 +- firewall/static/firewall/firewallV2.js | 2265 +++++++++++++++++ firewall/templates/firewall/csfV2.html | 253 ++ firewall/templates/firewall/firewallV2.html | 130 + firewall/templates/firewall/imunifyAVV2.html | 80 + firewall/templates/firewall/imunifyV2.html | 92 + .../firewall/modSecurityRulesPacksV2.html | 131 + .../firewall/modSecurityRulesV2.html | 69 + .../templates/firewall/modSecurityV2.html | 381 +++ .../templates/firewall/notAvailableAVV2.html | 58 + .../templates/firewall/notAvailableV2.html | 78 + firewall/templates/firewall/secureSSHV2.html | 160 ++ firewall/urls.py | 15 +- firewall/views.py | 179 +- .../templates/mailServer/listEmailsV2.html | 2 +- managePHP/static/managePHP/managePHPV2.js | 654 +++++ .../templates/managePHP/editPHPConfigV2.html | 223 ++ .../managePHP/installExtensionsV2.html | 139 + managePHP/urls.py | 5 +- managePHP/views.py | 1276 +++++++++- serverLogs/static/serverLogs/serverLogsV2.js | 915 +++++++ .../templates/serverLogs/accessLogsV2.html | 45 + .../templates/serverLogs/emailLogsV2.html | 45 + .../templates/serverLogs/errorLogsV2.html | 45 + .../templates/serverLogs/ftplogsV2.html | 45 + .../serverLogs/modSecAuditLogV2.html | 45 + .../templates/serverLogs/serverMailV2.html | 78 + serverLogs/urls.py | 16 +- serverLogs/views.py | 61 +- .../static/serverStatus/serverStatusV2.js | 650 +++++ .../serverStatus/cybercpmainlogfile.html | 45 +- .../serverStatus/cybercpmainlogfileV2.html | 42 + .../serverStatus/litespeedStatusV2.html | 356 +++ .../serverStatus/topProcessesV2.html | 336 +++ serverStatus/urls.py | 7 +- serverStatus/views.py | 119 +- tuning/static/tuning/tuningV2.js | 350 +++ .../templates/tuning/liteSpeedTuningV2.html | 105 + tuning/templates/tuning/phpTuningV2.html | 266 ++ tuning/tuning.py | 21 +- tuning/urls.py | 8 +- tuning/views.py | 26 +- 56 files changed, 13579 insertions(+), 312 deletions(-) create mode 100644 baseTemplate/templates/baseTemplate/FileManagerTRY.html create mode 100644 dockerManager/static/dockerManager/dockerManagerV2.js create mode 100644 dockerManager/templates/dockerManager/imagesV2.html create mode 100644 dockerManager/templates/dockerManager/listContainersV2.html create mode 100644 dockerManager/templates/dockerManager/manageImagesV2.html create mode 100644 dockerManager/templates/dockerManager/runContainerV2.html create mode 100644 dockerManager/templates/dockerManager/viewContainerV2.html create mode 100644 firewall/static/firewall/firewallV2.js create mode 100644 firewall/templates/firewall/csfV2.html create mode 100644 firewall/templates/firewall/firewallV2.html create mode 100644 firewall/templates/firewall/imunifyAVV2.html create mode 100644 firewall/templates/firewall/imunifyV2.html create mode 100644 firewall/templates/firewall/modSecurityRulesPacksV2.html create mode 100644 firewall/templates/firewall/modSecurityRulesV2.html create mode 100644 firewall/templates/firewall/modSecurityV2.html create mode 100644 firewall/templates/firewall/notAvailableAVV2.html create mode 100644 firewall/templates/firewall/notAvailableV2.html create mode 100644 firewall/templates/firewall/secureSSHV2.html create mode 100644 managePHP/static/managePHP/managePHPV2.js create mode 100644 managePHP/templates/managePHP/editPHPConfigV2.html create mode 100644 managePHP/templates/managePHP/installExtensionsV2.html create mode 100644 serverLogs/static/serverLogs/serverLogsV2.js create mode 100644 serverLogs/templates/serverLogs/accessLogsV2.html create mode 100644 serverLogs/templates/serverLogs/emailLogsV2.html create mode 100644 serverLogs/templates/serverLogs/errorLogsV2.html create mode 100644 serverLogs/templates/serverLogs/ftplogsV2.html create mode 100644 serverLogs/templates/serverLogs/modSecAuditLogV2.html create mode 100644 serverLogs/templates/serverLogs/serverMailV2.html create mode 100644 serverStatus/static/serverStatus/serverStatusV2.js create mode 100644 serverStatus/templates/serverStatus/cybercpmainlogfileV2.html create mode 100644 serverStatus/templates/serverStatus/litespeedStatusV2.html create mode 100644 serverStatus/templates/serverStatus/topProcessesV2.html create mode 100644 tuning/static/tuning/tuningV2.js create mode 100644 tuning/templates/tuning/liteSpeedTuningV2.html create mode 100644 tuning/templates/tuning/phpTuningV2.html diff --git a/baseTemplate/templates/baseTemplate/FileManagerTRY.html b/baseTemplate/templates/baseTemplate/FileManagerTRY.html new file mode 100644 index 000000000..a33f4a364 --- /dev/null +++ b/baseTemplate/templates/baseTemplate/FileManagerTRY.html @@ -0,0 +1,167 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + + {% trans "File Manager - CyberPanel" %} + + + + + {% load static %} + + + + + + + + + + + + + + + + + + + + + +
+
+
+

Current Path

+
+
+ +
+
+ +
+
+ +
+{% endblock %} \ No newline at end of file diff --git a/baseTemplate/templates/baseTemplate/FileManagerV2.html b/baseTemplate/templates/baseTemplate/FileManagerV2.html index a33f4a364..f2b20b0b9 100644 --- a/baseTemplate/templates/baseTemplate/FileManagerV2.html +++ b/baseTemplate/templates/baseTemplate/FileManagerV2.html @@ -3,61 +3,77 @@ {% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} {% block newContent %} - - {% trans "File Manager - CyberPanel" %} - - - + {# #} + {# {% trans "File Manager - CyberPanel" %}#} + {# #} + {# #} + {# #} + {##} + {# {% load static %}#} + {# #} + {##} + {# #} + {##} + {##} + {# #} + {# #} + {# #} + {# #} + {# #} + {##} + {# #} + {# #} + {##} + {##} + {# #} + {##} + {# #} - {% load static %} - + - + + + + + + + + - - +
- - - - - +
+ + {{ domainName }} +
- - - - - - - - -
-
+

Current Path

-
@@ -65,49 +81,670 @@
    -
  • - {% trans "Upload" %} +
  • + {% trans "Upload" %} +
  • -
  • - {% trans "New File" %} +
  • + {% trans "New File" %} + +
  • -
  • - {% trans "New Folder" %} +
  • + {% trans "New Folder" %} + +
  • - {% trans "Delete" %} +
  • -
  • - + {% trans "Copy" %} +
  • -
  • - + {% trans "Move" %} +
  • -
  • - + {% trans "Rename" %} +
  • - {% trans "Edit" %} + {% trans "Edit" %} +
  • - {% trans "Compress" %} +
  • - {% trans "Extract" %} + {% trans "Extract" %} + +
  • +
  • + {% trans "Fix Permissions" %} +
  • +
+
+
@@ -139,20 +776,23 @@
-
+
- - + + - - - @@ -163,5 +803,65 @@ + + {% endblock %} \ No newline at end of file diff --git a/baseTemplate/templates/baseTemplate/newBase.html b/baseTemplate/templates/baseTemplate/newBase.html index 64791d557..74cf561e0 100644 --- a/baseTemplate/templates/baseTemplate/newBase.html +++ b/baseTemplate/templates/baseTemplate/newBase.html @@ -1036,7 +1036,7 @@
+
+ + File Name + Size (KB) + Last Modified + Permissions
+ + + + + + + + + {% for name, image in images.items %} + + + + + + {% endfor %} + +
+ Name (Installed) + + Tags + + Action +
{{ image.name }} + + + {% trans "Create" %} +
+
+
+
+{% endblock %} diff --git a/dockerManager/templates/dockerManager/listContainersV2.html b/dockerManager/templates/dockerManager/listContainersV2.html new file mode 100644 index 000000000..2e876eb65 --- /dev/null +++ b/dockerManager/templates/dockerManager/listContainersV2.html @@ -0,0 +1,219 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+
+
+

List Containers

+
+
+ +
+

Manage containers on server

+
+
+
+
+

Containers

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Name + + Launch + + Owner + + Image + + Tag + + Actions +
+ + + + +
+
+
+

{% trans "Error message:" %} {$ errorMessage $}

+
+
+ +
+ {% if showUnlistedContainer %} +

+ {% trans "Unlisted Containers" %} +

+
+ + + + + + + + + + {% for container in unlistedContainers %} + + + + + + {% endfor %} + +
+ Name + + Status + + Actions +
{{ container.name }}{{ container.status }} + + + +
+
+ {% endif %} +
+
+ + +{% endblock %} diff --git a/dockerManager/templates/dockerManager/manageImagesV2.html b/dockerManager/templates/dockerManager/manageImagesV2.html new file mode 100644 index 000000000..c6983c252 --- /dev/null +++ b/dockerManager/templates/dockerManager/manageImagesV2.html @@ -0,0 +1,209 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+
+
+

Manage Images

+
+
+ +
+

On this page you can manage docker images.

+
+
+
+
+

Images

+ +
+
+ +
+
+
+
+

Search Image

+
+
+ +
+
+
+ + + + + + + + + + + + + + + +
+ Name (search) + + Tags + + Action +
+ + + + + + + + + {% trans "Pull" %} +
+
+
+ + + + + + + + + + {% for name, image in images.items %} + + + + + + {% endfor %} + +
+ Name (Locally Available) + + Tags + + Action +
+ {{ image.name }} + + + + + + +
+
+
+
+{% endblock %} diff --git a/dockerManager/templates/dockerManager/runContainerV2.html b/dockerManager/templates/dockerManager/runContainerV2.html new file mode 100644 index 000000000..2edc6f7c9 --- /dev/null +++ b/dockerManager/templates/dockerManager/runContainerV2.html @@ -0,0 +1,209 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+
+
+

Run Container

+
+
+
+

Modify parameters for your new container

+
+
+
+
+

Container Details

+ +
+
+
+
+

Name

+
+
+ +
+
+
+
+

Image

+
+
+ +
+
+
+
+

Tag

+
+
+ +
+
+
+
+

Select Owner

+
+
+ +
+
+
+
+

Memory limit

+
+
+ +
+
+

MB

+
+
+ {% for port, protocol in portConfig.items %} +
+
+

Port

+
+
+ +
+
+ +
+
+

to

+
+
+ +
+
+ {% endfor %} + + {% for env, value in envList.items %} + + {% endfor %} +
+
+

+ ENV +

+
+
+
+

+
+ {#

#} +
+ +
+
+ +
+
+
+ +
+
+
+
+

+ Map Volumes +

+
+
+
+

+
+ {#

#} +
+ +
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+

{$ currentStatus $}

+
+
+
+
+
+
+

{% trans "Error message:" %} {$ errorMessage $}

+
+
+

{% trans "Container succesfully created." %}

+
+
+

{% trans "Could not connect to server. Please refresh this page." %}

+
+
+ +
+ +
+
+
+{% endblock %} diff --git a/dockerManager/templates/dockerManager/viewContainerV2.html b/dockerManager/templates/dockerManager/viewContainerV2.html new file mode 100644 index 000000000..47c8b14aa --- /dev/null +++ b/dockerManager/templates/dockerManager/viewContainerV2.html @@ -0,0 +1,438 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+
+
+

Manage Container

+
+
+
+

Currently managing: {{ name }}

+
+
+
+

Container Information

+ +
+
+
+
+
+

Memory Usage

+
+
+
+
{{ memoryUsage | floatformat:"2" }}% +
+
+
+
+

CPU Usage

+
+
+
+
{{ cpuUsage }}% +
+
+
+
+
+
+
+ {% trans "Container ID" %}: {{ cid }} +
+ {% trans "Image" %}: {{ image }} + + + +
+ {% if ports %} + {% trans "Ports" %}:
+ {% for iport, eport in ports.items %} + {{ iport }} {% trans "to" %} {{ eport }}
+ {% endfor %} + {% endif %} +
+ + + +
+
+
+
+
+
+
+

Actions

+
+
+
+
+
+

Main Actions

+ +
+
+ +
+
+
+

Status:

+ +
+
+
+ + + +

Start

+
+
+ + + +

Restart

+
+
+ + + +

Stop

+
+
+ + + +

Remove

+
+
+
+
+
+
+

Other Actions

+
+
+
+

Restart on system reboot:

+ +
+
+ + + +
+
+
+
+
+
+

Logs

+ + + + +
+
+
+
+
+
+{% endblock %} diff --git a/dockerManager/urls.py b/dockerManager/urls.py index 64209963e..e4c285bb4 100755 --- a/dockerManager/urls.py +++ b/dockerManager/urls.py @@ -3,11 +3,13 @@ from . import views urlpatterns = [ url(r'^$', views.loadDockerHome, name='dockerHome'), -# url(r'^images', views.loadImages, name='loadImages'), + # url(r'^images', views.loadImages, name='loadImages'), url(r'^getTags', views.getTags, name='getTags'), url(r'^runContainer', views.runContainer, name='runContainer'), + url(r'^V2/runContainerV2', views.runContainerV2, name='runContainerV2'), url(r'^submitContainerCreation', views.submitContainerCreation, name='submitContainerCreation'), url(r'^listContainers', views.listContainers, name='listContainers'), + url(r'^V2/listContainersV2', views.listContainersV2, name='listContainersV2'), url(r'^getContainerList', views.getContainerList, name='getContainerList'), url(r'^getContainerLogs', views.getContainerLogs, name='getContainerLogs'), url(r'^installImage', views.installImage, name='installImage'), @@ -20,10 +22,13 @@ urlpatterns = [ url(r'^assignContainer', views.assignContainer, name='assignContainer'), url(r'^searchImage', views.searchImage, name='searchImage'), url(r'^manageImages', views.manageImages, name='manageImages'), + url(r'^V2/manageImagesV2', views.manageImagesV2, name='manageImagesV2'), url(r'^getImageHistory', views.getImageHistory, name='getImageHistory'), url(r'^removeImage', views.removeImage, name='removeImage'), url(r'^recreateContainer', views.recreateContainer, name='recreateContainer'), url(r'^installDocker', views.installDocker, name='installDocker'), url(r'^images', views.images, name='containerImage'), + url(r'^V2/imagesV2', views.imagesV2, name='containerImageV2'), url(r'^view/(?P(.*))$', views.viewContainer, name='viewContainer'), -] \ No newline at end of file + url(r'^V2/view/(?P(.*))$', views.viewContainerV2, name='viewContainerV2'), +] diff --git a/dockerManager/views.py b/dockerManager/views.py index f2f3259d1..cd8ef23ff 100755 --- a/dockerManager/views.py +++ b/dockerManager/views.py @@ -1,4 +1,4 @@ - # -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- from django.shortcuts import redirect, HttpResponse @@ -10,14 +10,14 @@ from .decorators import preDockerRun from plogical.acl import ACLManager import json + # Create your views here. # This function checks if user has admin permissions def dockerPermission(request, userID, context): - currentACL = ACLManager.loadedACL(userID) - + if currentACL['admin'] != 1: if request.method == "POST": return ACLManager.loadErrorJson() @@ -25,7 +25,8 @@ def dockerPermission(request, userID, context): return ACLManager.loadError() else: return 0 - + + @preDockerRun def loadDockerHome(request): userID = request.session['userID'] @@ -34,6 +35,7 @@ def loadDockerHome(request): proc = httpProc(request, template, {"type": admin.type}, 'admin') return proc.render() + def installDocker(request): try: @@ -57,7 +59,8 @@ def installDocker(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) -@preDockerRun + +@preDockerRun def installImage(request): try: userID = request.session['userID'] @@ -75,7 +78,8 @@ def installImage(request): except KeyError: return redirect(loadLoginPage) - + + @preDockerRun def viewContainer(request, name): try: @@ -97,10 +101,35 @@ def viewContainer(request, name): return coreResult except KeyError: - return redirect(loadLoginPage) + return redirect(loadLoginPage) + @preDockerRun -def getTags(request): +def viewContainerV2(request, name): + try: + if not request.GET._mutable: + request.GET._mutable = True + request.GET['name'] = name + + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + + cm = ContainerManager(name) + coreResult = cm.loadContainerHomeV2(request, userID) + + return coreResult + + except KeyError: + return redirect(loadLoginPage) + + +@preDockerRun +def getTags(request): try: userID = request.session['userID'] currentACL = ACLManager.loadedACL(userID) @@ -117,9 +146,10 @@ def getTags(request): except KeyError: return redirect(loadLoginPage) - + + @preDockerRun -def delContainer(request): +def delContainer(request): try: userID = request.session['userID'] @@ -137,9 +167,10 @@ def delContainer(request): except KeyError: return redirect(loadLoginPage) - -@preDockerRun -def recreateContainer(request): + + +@preDockerRun +def recreateContainer(request): try: userID = request.session['userID'] currentACL = ACLManager.loadedACL(userID) @@ -155,9 +186,10 @@ def recreateContainer(request): return coreResult except KeyError: - return redirect(loadLoginPage) - -@preDockerRun + return redirect(loadLoginPage) + + +@preDockerRun def runContainer(request): try: userID = request.session['userID'] @@ -167,13 +199,31 @@ def runContainer(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() return cm.createContainer(request, userID) except KeyError: - return redirect(loadLoginPage) + return redirect(loadLoginPage) -@preDockerRun + +@preDockerRun +def runContainerV2(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + + cm = ContainerManager() + return cm.createContainerV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + +@preDockerRun def listContainers(request): try: userID = request.session['userID'] @@ -182,7 +232,18 @@ def listContainers(request): except KeyError: return redirect(loadLoginPage) -@preDockerRun + +@preDockerRun +def listContainersV2(request): + try: + userID = request.session['userID'] + cm = ContainerManager() + return cm.listContainersV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + +@preDockerRun def getContainerLogs(request): try: @@ -199,9 +260,10 @@ def getContainerLogs(request): return coreResult except KeyError: - return redirect(loadLoginPage) + return redirect(loadLoginPage) -@preDockerRun + +@preDockerRun def submitContainerCreation(request): try: @@ -221,7 +283,8 @@ def submitContainerCreation(request): except KeyError: return redirect(loadLoginPage) -@preDockerRun + +@preDockerRun def getContainerList(request): try: userID = request.session['userID'] @@ -231,13 +294,14 @@ def getContainerList(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() return cm.getContainerList(userID, json.loads(request.body)) except KeyError: return redirect(loadLoginPage) -@preDockerRun + +@preDockerRun def doContainerAction(request): try: userID = request.session['userID'] @@ -247,15 +311,16 @@ def doContainerAction(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() coreResult = cm.doContainerAction(userID, json.loads(request.body)) - + return coreResult except KeyError: return redirect(loadLoginPage) -@preDockerRun + +@preDockerRun def getContainerStatus(request): try: userID = request.session['userID'] @@ -265,15 +330,16 @@ def getContainerStatus(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() coreResult = cm.getContainerStatus(userID, json.loads(request.body)) - + return coreResult except KeyError: - return redirect(loadLoginPage) + return redirect(loadLoginPage) -@preDockerRun + +@preDockerRun def exportContainer(request): try: userID = request.session['userID'] @@ -283,15 +349,16 @@ def exportContainer(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() coreResult = cm.exportContainer(request, userID) - + return coreResult except KeyError: - return redirect(loadLoginPage) - -@preDockerRun + return redirect(loadLoginPage) + + +@preDockerRun def saveContainerSettings(request): try: userID = request.session['userID'] @@ -301,15 +368,16 @@ def saveContainerSettings(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() coreResult = cm.saveContainerSettings(userID, json.loads(request.body)) - + return coreResult except KeyError: - return redirect(loadLoginPage) - -@preDockerRun + return redirect(loadLoginPage) + + +@preDockerRun def getContainerTop(request): try: userID = request.session['userID'] @@ -319,15 +387,16 @@ def getContainerTop(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() coreResult = cm.getContainerTop(userID, json.loads(request.body)) - + return coreResult except KeyError: return redirect(loadLoginPage) -@preDockerRun + +@preDockerRun def assignContainer(request): try: userID = request.session['userID'] @@ -337,15 +406,16 @@ def assignContainer(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() coreResult = cm.assignContainer(userID, json.loads(request.body)) - + return coreResult except KeyError: return redirect(loadLoginPage) - -@preDockerRun + + +@preDockerRun def searchImage(request): try: userID = request.session['userID'] @@ -355,27 +425,42 @@ def searchImage(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() coreResult = cm.searchImage(userID, json.loads(request.body)) - + return coreResult except KeyError: return redirect(loadLoginPage) - -@preDockerRun + + +@preDockerRun def images(request): try: userID = request.session['userID'] cm = ContainerManager() coreResult = cm.images(request, userID) - + return coreResult except KeyError: return redirect(loadLoginPage) - -@preDockerRun + + +@preDockerRun +def imagesV2(request): + try: + + userID = request.session['userID'] + cm = ContainerManager() + coreResult = cm.imagesV2(request, userID) + + return coreResult + except KeyError: + return redirect(loadLoginPage) + + +@preDockerRun def manageImages(request): try: userID = request.session['userID'] @@ -384,8 +469,20 @@ def manageImages(request): return coreResult except KeyError: return redirect(loadLoginPage) - -@preDockerRun + + +@preDockerRun +def manageImagesV2(request): + try: + userID = request.session['userID'] + cm = ContainerManager() + coreResult = cm.manageImagesV2(request, userID) + return coreResult + except KeyError: + return redirect(loadLoginPage) + + +@preDockerRun def getImageHistory(request): try: userID = request.session['userID'] @@ -395,15 +492,16 @@ def getImageHistory(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() coreResult = cm.getImageHistory(userID, json.loads(request.body)) - + return coreResult except KeyError: return redirect(loadLoginPage) - -@preDockerRun + + +@preDockerRun def removeImage(request): try: userID = request.session['userID'] @@ -413,10 +511,10 @@ def removeImage(request): pass else: return ACLManager.loadErrorJson() - + cm = ContainerManager() coreResult = cm.removeImage(userID, json.loads(request.body)) - + return coreResult except KeyError: - return redirect(loadLoginPage) \ No newline at end of file + return redirect(loadLoginPage) diff --git a/filemanager/urls.py b/filemanager/urls.py index 2e02a499e..0057d9d2d 100755 --- a/filemanager/urls.py +++ b/filemanager/urls.py @@ -2,13 +2,13 @@ from django.conf.urls import url from . import views urlpatterns = [ - url(r'^upload$',views.upload, name='upload'), - 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'^upload$', views.upload, name='upload'), + 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('^V2/FilemanagerV2', views.FileManagerRootV2, name='FilemanagerV2'), url(r'^(?P(.*))$', views.loadFileManagerHome, name='loadFileManagerHome'), ] - diff --git a/filemanager/views.py b/filemanager/views.py index ea22ed1c9..75510a913 100755 --- a/filemanager/views.py +++ b/filemanager/views.py @@ -29,6 +29,7 @@ def loadFileManagerHome(request, domain): except KeyError: return redirect(loadLoginPage) + def loadFileManagerHomeV2(request, domain): try: userID = request.session['userID'] @@ -267,7 +268,55 @@ def FileManagerRoot(request): 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): diff --git a/firewall/firewallManager.py b/firewall/firewallManager.py index d4197bf5d..83c04a8e3 100755 --- a/firewall/firewallManager.py +++ b/firewall/firewallManager.py @@ -24,21 +24,21 @@ from plogical.csf import CSF from plogical.processUtilities import ProcessUtilities from serverStatus.serverStatusUtil import ServerStatusUtil -class FirewallManager: +class FirewallManager: imunifyPath = '/usr/bin/imunify360-agent' CLPath = '/etc/sysconfig/cloudlinux' imunifyAVPath = '/etc/sysconfig/imunify360/integration.conf' - def __init__(self, request = None): + def __init__(self, request=None): self.request = request - def securityHome(self, request = None, userID = None): + def securityHome(self, request=None, userID=None): proc = httpProc(request, 'firewall/index.html', None, 'admin') return proc.render() - def firewallHome(self, request = None, userID = None): + def firewallHome(self, request=None, userID=None): csfPath = '/etc/csf' if os.path.exists(csfPath): @@ -48,7 +48,17 @@ class FirewallManager: None, 'admin') return proc.render() - def getCurrentRules(self, userID = None): + def firewallHomeV2(self, request=None, userID=None): + csfPath = '/etc/csf' + + if os.path.exists(csfPath): + return redirect('/configservercsf/') + else: + proc = httpProc(request, 'firewall/firewallV2.html', + None, 'admin') + return proc.render() + + def getCurrentRules(self, userID=None): try: currentACL = ACLManager.loadedACL(userID) @@ -64,12 +74,12 @@ class FirewallManager: for items in rules: dic = { - 'id': items.id, - 'name': items.name, - 'proto': items.proto, - 'port': items.port, - 'ipAddress': items.ipAddress, - } + 'id': items.id, + 'name': items.name, + 'proto': items.proto, + 'port': items.port, + 'ipAddress': items.ipAddress, + } if checker == 0: json_data = json_data + json.dumps(dic) @@ -86,7 +96,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def addRule(self, userID = None, data = None): + def addRule(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -95,7 +105,6 @@ class FirewallManager: else: return ACLManager.loadErrorJson('add_status', 0) - ruleName = data['ruleName'] ruleProtocol = data['ruleProtocol'] rulePort = data['rulePort'] @@ -115,7 +124,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def deleteRule(self, userID = None, data = None): + def deleteRule(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -125,7 +134,6 @@ class FirewallManager: else: return ACLManager.loadErrorJson('delete_status', 0) - ruleID = data['id'] ruleProtocol = data['proto'] rulePort = data['port'] @@ -145,7 +153,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def reloadFirewall(self, userID = None, data = None): + def reloadFirewall(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -173,7 +181,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def startFirewall(self, userID = None, data = None): + def startFirewall(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -201,7 +209,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def stopFirewall(self, userID = None, data = None): + def stopFirewall(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -229,7 +237,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def firewallStatus(self, userID = None, data = None): + def firewallStatus(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -256,12 +264,17 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def secureSSH(self, request = None, userID = None): + def secureSSH(self, request=None, userID=None): proc = httpProc(request, 'firewall/secureSSH.html', None, 'admin') return proc.render() - def getSSHConfigs(self, userID = None, data = None): + def secureSSHV2(self, request=None, userID=None): + proc = httpProc(request, 'firewall/secureSSHV2.html', + None, 'admin') + return proc.render() + + def getSSHConfigs(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -320,8 +333,6 @@ class FirewallManager: key = "ssh-rsa " + keydata[1][:50] userName = '' - - dic = {'userName': userName, 'key': key, } @@ -342,7 +353,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def saveSSHConfigs(self, userID = None, data = None): + def saveSSHConfigs(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -361,7 +372,8 @@ class FirewallManager: rootLogin = "0" execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py" - execPath = execPath + " saveSSHConfigs --type " + str(type) + " --sshPort " + sshPort + " --rootLogin " + rootLogin + execPath = execPath + " saveSSHConfigs --type " + str( + type) + " --sshPort " + sshPort + " --rootLogin " + rootLogin output = ProcessUtilities.outputExecutioner(execPath) @@ -400,11 +412,11 @@ class FirewallManager: return HttpResponse(final_json) except BaseException as msg: - final_dic = {'status': 0 ,'saveStatus': 0, 'error_message': str(msg)} + final_dic = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) - def deleteSSHKey(self, userID = None, data = None): + def deleteSSHKey(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -434,7 +446,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def addSSHKey(self, userID = None, data = None): + def addSSHKey(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -470,7 +482,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def loadModSecurityHome(self, request = None, userID = None): + def loadModSecurityHome(self, request=None, userID=None): if ProcessUtilities.decideServer() == ProcessUtilities.OLS: OLS = 1 confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") @@ -492,7 +504,29 @@ class FirewallManager: {'modSecInstalled': modSecInstalled, 'OLS': OLS}, 'admin') return proc.render() - def installModSec(self, userID = None, data = None): + def loadModSecurityHomeV2(self, request=None, userID=None): + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + OLS = 1 + confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + + command = "sudo cat " + confPath + httpdConfig = ProcessUtilities.outputExecutioner(command).splitlines() + + modSecInstalled = 0 + + for items in httpdConfig: + if items.find('module mod_security') > -1: + modSecInstalled = 1 + break + else: + OLS = 0 + modSecInstalled = 1 + + proc = httpProc(request, 'firewall/modSecurityV2.html', + {'modSecInstalled': modSecInstalled, 'OLS': OLS}, 'admin') + return proc.render() + + def installModSec(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -516,7 +550,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def installStatusModSec(self, userID = None, data = None): + def installStatusModSec(self, userID=None, data=None): try: command = "sudo cat " + modSec.installLogPath @@ -570,7 +604,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def fetchModSecSettings(self, userID = None, data = None): + def fetchModSecSettings(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -711,7 +745,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def saveModSecConfigurations(self, userID = None, data = None): + def saveModSecConfigurations(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -752,7 +786,6 @@ class FirewallManager: ## writing data temporary to file - tempConfigPath = "/home/cyberpanel/" + str(randint(1000, 9999)) confPath = open(tempConfigPath, "w") @@ -808,7 +841,6 @@ class FirewallManager: ## writing data temporary to file - tempConfigPath = "/home/cyberpanel/" + str(randint(1000, 9999)) confPath = open(tempConfigPath, "w") @@ -844,7 +876,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - def modSecRules(self, request = None, userID = None): + def modSecRules(self, request=None, userID=None): if ProcessUtilities.decideServer() == ProcessUtilities.OLS: confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") @@ -864,7 +896,27 @@ class FirewallManager: {'modSecInstalled': modSecInstalled}, 'admin') return proc.render() - def fetchModSecRules(self, userID = None, data = None): + def modSecRulesV2(self, request=None, userID=None): + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + + command = "sudo cat " + confPath + httpdConfig = ProcessUtilities.outputExecutioner(command).split('\n') + + modSecInstalled = 0 + + for items in httpdConfig: + if items.find('module mod_security') > -1: + modSecInstalled = 1 + break + else: + modSecInstalled = 1 + + proc = httpProc(request, 'firewall/modSecurityRulesV2.html', + {'modSecInstalled': modSecInstalled}, 'admin') + return proc.render() + + def fetchModSecRules(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -921,7 +973,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def saveModSecRules(self, userID = None, data = None): + def saveModSecRules(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -958,7 +1010,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - def modSecRulesPacks(self, request = None, userID = None): + def modSecRulesPacks(self, request=None, userID=None): if ProcessUtilities.decideServer() == ProcessUtilities.OLS: confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") @@ -979,7 +1031,28 @@ class FirewallManager: {'modSecInstalled': modSecInstalled}, 'admin') return proc.render() - def getOWASPAndComodoStatus(self, userID = None, data = None): + def modSecRulesPacksV2(self, request=None, userID=None): + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + + confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") + + command = "sudo cat " + confPath + httpdConfig = ProcessUtilities.outputExecutioner(command).split('\n') + + modSecInstalled = 0 + + for items in httpdConfig: + if items.find('module mod_security') > -1: + modSecInstalled = 1 + break + else: + modSecInstalled = 1 + + proc = httpProc(request, 'firewall/modSecurityRulesPacksV2.html', + {'modSecInstalled': modSecInstalled}, 'admin') + return proc.render() + + def getOWASPAndComodoStatus(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -1069,7 +1142,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def installModSecRulesPack(self, userID = None, data = None): + def installModSecRulesPack(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -1119,7 +1192,7 @@ class FirewallManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) - def getRulesFiles(self, userID = None, data = None): + def getRulesFiles(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -1255,7 +1328,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def enableDisableRuleFile(self, userID = None, data = None): + def enableDisableRuleFile(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -1307,6 +1380,20 @@ class FirewallManager: {'csfInstalled': csfInstalled}, 'admin') return proc.render() + def csfV2(self): + csfInstalled = 1 + try: + command = 'csf -h' + output = ProcessUtilities.outputExecutioner(command) + if output.find("command not found") > -1: + csfInstalled = 0 + except subprocess.CalledProcessError: + csfInstalled = 0 + + proc = httpProc(self.request, 'firewall/csfV2.html', + {'csfInstalled': csfInstalled}, 'admin') + return proc.render() + def installCSF(self): try: userID = self.request.session['userID'] @@ -1339,39 +1426,39 @@ class FirewallManager: installStatus = ProcessUtilities.outputExecutioner("sudo cat " + CSF.installLogPath) - if installStatus.find("[200]")>-1: + if installStatus.find("[200]") > -1: command = 'sudo rm -f ' + CSF.installLogPath ProcessUtilities.executioner(command) final_json = json.dumps({ - 'error_message': "None", - 'requestStatus': installStatus, - 'abort':1, - 'installed': 1, - }) + 'error_message': "None", + 'requestStatus': installStatus, + 'abort': 1, + 'installed': 1, + }) return HttpResponse(final_json) elif installStatus.find("[404]") > -1: command = 'sudo rm -f ' + CSF.installLogPath ProcessUtilities.executioner(command) final_json = json.dumps({ - 'abort':1, - 'installed':0, - 'error_message': "None", - 'requestStatus': installStatus, - }) + 'abort': 1, + 'installed': 0, + 'error_message': "None", + 'requestStatus': installStatus, + }) return HttpResponse(final_json) else: final_json = json.dumps({ - 'abort':0, - 'error_message': "None", - 'requestStatus': installStatus, - }) + 'abort': 0, + 'error_message': "None", + 'requestStatus': installStatus, + }) return HttpResponse(final_json) except BaseException as msg: - final_dic = {'abort':1, 'installed':0, 'error_message': str(msg)} + final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -1413,9 +1500,8 @@ class FirewallManager: currentSettings = CSF.fetchCSFSettings() - - data_ret = {"fetchStatus": 1, 'testingMode' : currentSettings['TESTING'], - 'tcpIN' : currentSettings['tcpIN'], + data_ret = {"fetchStatus": 1, 'testingMode': currentSettings['TESTING'], + 'tcpIN': currentSettings['tcpIN'], 'tcpOUT': currentSettings['tcpOUT'], 'udpIN': currentSettings['udpIN'], 'udpOUT': currentSettings['udpOUT'], @@ -1462,7 +1548,7 @@ class FirewallManager: final_json = json.dumps(final_dic) return HttpResponse(final_json) - def modifyPorts(self, data = None): + def modifyPorts(self, data=None): try: userID = self.request.session['userID'] @@ -1567,6 +1653,37 @@ class FirewallManager: data, 'admin') return proc.render() + def imunifyV2(self): + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + ipAddress = ipData.split('\n', 1)[0] + + fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort()) + + data = {} + data['ipAddress'] = fullAddress + + data['CL'] = 1 + + if os.path.exists(FirewallManager.imunifyPath): + data['imunify'] = 1 + else: + data['imunify'] = 0 + + if data['CL'] == 0: + proc = httpProc(self.request, 'firewall/notAvailableV2.html', + data, 'admin') + return proc.render() + elif data['imunify'] == 0: + proc = httpProc(self.request, 'firewall/notAvailableV2.html', + data, 'admin') + return proc.render() + else: + proc = httpProc(self.request, 'firewall/imunifyV2.html', + data, 'admin') + return proc.render() + def submitinstallImunify(self): try: userID = self.request.session['userID'] @@ -1618,6 +1735,31 @@ class FirewallManager: data, 'admin') return proc.render() + def imunifyAVV2(self): + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + ipAddress = ipData.split('\n', 1)[0] + + fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort()) + + data = {} + data['ipAddress'] = fullAddress + + if os.path.exists(FirewallManager.imunifyAVPath): + data['imunify'] = 1 + else: + data['imunify'] = 0 + + if data['imunify'] == 0: + proc = httpProc(self.request, 'firewall/notAvailableAVV2.html', + data, 'admin') + return proc.render() + else: + proc = httpProc(self.request, 'firewall/imunifyAVV2.html', + data, 'admin') + return proc.render() + def submitinstallImunifyAV(self): try: userID = self.request.session['userID'] diff --git a/firewall/static/firewall/firewallV2.js b/firewall/static/firewall/firewallV2.js new file mode 100644 index 000000000..7cef23a57 --- /dev/null +++ b/firewall/static/firewall/firewallV2.js @@ -0,0 +1,2265 @@ +newapp.controller('firewallControllerV2', function ($scope, $http) { + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + $scope.rulesDetails = false; + + firewallStatus(); + + populateCurrentRecords(); + + $scope.addRule = function () { + + $scope.rulesLoading = false; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + + url = "/firewall/addRule"; + + + var ruleName = $scope.ruleName; + var ruleProtocol = $scope.ruleProtocol; + var rulePort = $scope.rulePort; + + + var data = { + ruleName: ruleName, + ruleProtocol: ruleProtocol, + rulePort: rulePort, + ruleIP: $scope.ruleIP, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.add_status == 1) { + + + populateCurrentRecords(); + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = false; + $scope.couldNotConnect = true; + + + } else { + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = false; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = false; + + + } + + }; + + function populateCurrentRecords() { + + $scope.rulesLoading = false; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + + url = "/firewall/getCurrentRules"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + if (response.data.fetchStatus === 1) { + $scope.rules = JSON.parse(response.data.data); + $scope.rulesLoading = true; + } else { + $scope.rulesLoading = true; + $scope.errorMessage = response.data.error_message; + } + } + + function cantLoadInitialDatas(response) { + $scope.couldNotConnect = false; + + } + + }; + + $scope.deleteRule = function (id, proto, port, ruleIP) { + + $scope.rulesLoading = false; + + url = "/firewall/deleteRule"; + + var data = { + id: id, + proto: proto, + port: port, + ruleIP: ruleIP + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.delete_status === 1) { + + + populateCurrentRecords(); + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + + } else { + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = false; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + $scope.rulesLoading = true; + $scope.errorMessage = response.data.error_message; + + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = false; + + + } + + + }; + + + $scope.reloadFireWall = function () { + + + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + $scope.rulesLoading = false; + + url = "/firewall/reloadFirewall"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.reload_status == 1) { + + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = false; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + + } else { + + $scope.rulesLoading = true; + $scope.actionFailed = false; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + $scope.errorMessage = response.data.error_message; + + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = false; + + + } + + + }; + + $scope.startFirewall = function () { + + + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + $scope.rulesLoading = false; + + url = "/firewall/startFirewall"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.start_status == 1) { + + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = false; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + $scope.rulesDetails = false; + + firewallStatus(); + + + } else { + + $scope.rulesLoading = true; + $scope.actionFailed = false; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + $scope.errorMessage = response.data.error_message; + + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = false; + + + } + + + }; + + + $scope.stopFirewall = function () { + + + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + $scope.rulesLoading = false; + + url = "/firewall/stopFirewall"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.stop_status == 1) { + + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = false; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + $scope.rulesDetails = true; + + firewallStatus(); + + + } else { + + $scope.rulesLoading = true; + $scope.actionFailed = false; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = true; + + $scope.errorMessage = response.data.error_message; + + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.rulesLoading = true; + $scope.actionFailed = true; + $scope.actionSuccess = true; + + $scope.canNotAddRule = true; + $scope.ruleAdded = true; + $scope.couldNotConnect = false; + + + } + + + }; + + + function firewallStatus() { + + + url = "/firewall/firewallStatus"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.status == 1) { + + if (response.data.firewallStatus == 1) { + $scope.rulesDetails = false; + $scope.status = "ON"; + } else { + $scope.rulesDetails = true; + $scope.status = "OFF"; + } + } else { + + $scope.rulesDetails = true; + $scope.status = "OFF"; + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.couldNotConnect = false; + + + } + + }; + + +}); +newapp.controller('secureSSHCTRLV2', function ($scope, $http) { + + $scope.couldNotSave = true; + $scope.detailsSaved = true; + $scope.couldNotConnect = true; + $scope.secureSSHLoading = true; + $scope.keyDeleted = true; + $scope.keyBox = true; + $scope.showKeyBox = false; + $scope.saveKeyBtn = true; + + $scope.addKey = function () { + $scope.saveKeyBtn = false; + $scope.showKeyBox = true; + $scope.keyBox = false; + }; + + + getSSHConfigs(); + populateCurrentKeys(); + + // Checking root login + + var rootLogin = false; + + $('#rootLogin').change(function () { + rootLogin = $(this).prop('checked'); + }); + + + function getSSHConfigs() { + + $scope.couldNotSave = true; + $scope.detailsSaved = true; + $scope.couldNotConnect = true; + $scope.secureSSHLoading = false; + + url = "/firewall/getSSHConfigs"; + + var data = { + type: "1", + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.sshPort = response.data.sshPort; + + if (response.data.permitRootLogin == 1) { + // $('#rootLogin').bootstrapToggle('on'); + $scope.couldNotSave = true; + $scope.detailsSaved = true; + $scope.couldNotConnect = true; + $scope.secureSSHLoading = true; + } else { + $scope.errorMessage = response.data.error_message; + $scope.couldNotSave = true; + $scope.detailsSaved = true; + $scope.couldNotConnect = true; + $scope.secureSSHLoading = true; + } + + } + + function cantLoadInitialDatas(response) { + $scope.couldNotConnect = false; + + } + + } + + $scope.saveChanges = function () { + + $scope.couldNotSave = true; + $scope.detailsSaved = true; + $scope.couldNotConnect = true; + $scope.secureSSHLoading = false; + + url = "/firewall/saveSSHConfigs"; + + var data = { + type: "1", + sshPort: $scope.sshPort, + rootLogin: rootLogin + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.saveStatus == 1) { + $scope.couldNotSave = true; + $scope.detailsSaved = false; + $scope.couldNotConnect = true; + $scope.secureSSHLoading = true; + } else { + + $scope.couldNotSave = false; + $scope.detailsSaved = true; + $scope.couldNotConnect = true; + $scope.secureSSHLoading = true; + + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + $scope.couldNotSave = true; + $scope.detailsSaved = true; + $scope.couldNotConnect = false; + $scope.secureSSHLoading = true; + + } + }; + + + function populateCurrentKeys() { + + url = "/firewall/getSSHConfigs"; + + var data = { + type: "2" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.records = JSON.parse(response.data.data); + } + } + + function cantLoadInitialDatas(response) { + $scope.couldNotConnect = false; + } + + + } + + $scope.deleteKey = function (key) { + + $scope.secureSSHLoading = false; + + url = "/firewall/deleteSSHKey"; + + var data = { + key: key, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.delete_status === 1) { + $scope.secureSSHLoading = true; + $scope.keyDeleted = false; + populateCurrentKeys(); + } else { + $scope.couldNotConnect = false; + $scope.secureSSHLoading = true; + } + + } + + function cantLoadInitialDatas(response) { + $scope.couldNotConnect = false; + $scope.secureSSHLoading = true; + + } + + + } + + $scope.saveKey = function (key) { + + $scope.secureSSHLoading = false; + + url = "/firewall/addSSHKey"; + + var data = { + key: $scope.keyData, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.add_status === 1) { + $scope.secureSSHLoading = true; + $scope.saveKeyBtn = true; + $scope.showKeyBox = false; + $scope.keyBox = true; + + + populateCurrentKeys(); + } else { + $scope.secureSSHLoading = true; + $scope.saveKeyBtn = false; + $scope.showKeyBox = true; + $scope.keyBox = true; + $scope.couldNotConnect = false; + $scope.secureSSHLoading = true; + } + + } + + function cantLoadInitialDatas(response) { + $scope.secureSSHLoading = true; + $scope.saveKeyBtn = false; + $scope.showKeyBox = true; + $scope.keyBox = true; + $scope.couldNotConnect = false; + $scope.secureSSHLoading = true; + + } + + + } + +}); +newapp.controller('modSecRulesV2', function ($scope, $http) { + + $scope.modsecLoading = true; + $scope.rulesSaved = true; + $scope.couldNotConnect = true; + $scope.couldNotSave = true; + + + fetchModSecRules(); + + function fetchModSecRules() { + + $scope.modsecLoading = false; + $scope.modsecLoading = true; + $scope.rulesSaved = true; + $scope.couldNotConnect = true; + + + url = "/firewall/fetchModSecRules"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.modsecLoading = true; + + if (response.data.modSecInstalled === 1) { + + $scope.currentModSecRules = response.data.currentModSecRules; + + } + + } + + function cantLoadInitialDatas(response) { + $scope.modsecLoading = true; + } + + } + + $scope.saveModSecRules = function () { + + $scope.modsecLoading = false; + $scope.rulesSaved = true; + $scope.couldNotConnect = true; + $scope.couldNotSave = true; + + + url = "/firewall/saveModSecRules"; + + var data = { + modSecRules: $scope.currentModSecRules + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.modsecLoading = true; + + if (response.data.saveStatus === 1) { + + $scope.rulesSaved = false; + $scope.couldNotConnect = true; + $scope.couldNotSave = true; + + } else { + $scope.rulesSaved = true; + $scope.couldNotConnect = true; + $scope.couldNotSave = false; + + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + $scope.modsecLoading = true; + $scope.rulesSaved = true; + $scope.couldNotConnect = false; + $scope.couldNotSave = true; + } + } + +}); +newapp.controller('modSecV2', function ($scope, $http, $timeout, $window) { + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = true; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + + $scope.installModSec = function () { + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = true; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + url = "/firewall/installModSec"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.installModSec === 1) { + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + getRequestStatus(); + + } else { + $scope.errorMessage = response.data.error_message; + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = true; + $scope.modsecLoading = true; + $scope.failedToStartInallation = false; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = false; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + } + + }; + + function getRequestStatus() { + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + url = "/firewall/installStatusModSec"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.abort === 0) { + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + $scope.requestData = response.data.requestStatus; + $timeout(getRequestStatus, 1000); + } else { + // Notifications + $timeout.cancel(); + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + + $scope.requestData = response.data.requestStatus; + + if (response.data.installed === 0) { + $scope.installationFailed = false; + $scope.errorMessage = response.data.error_message; + } else { + $scope.modSecSuccessfullyInstalled = false; + $timeout(function () { + $window.location.reload(); + }, 3000); + } + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = false; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + + } + + } + + ///// ModSec configs + + var modsecurity_status = false; + var SecAuditEngine = false; + var SecRuleEngine = false; + + + $('#modsecurity_status').change(function () { + modsecurity_status = $(this).prop('checked'); + }); + + $('#SecAuditEngine').change(function () { + SecAuditEngine = $(this).prop('checked'); + }); + + + $('#SecRuleEngine').change(function () { + SecRuleEngine = $(this).prop('checked'); + }); + + fetchModSecSettings(); + + function fetchModSecSettings() { + + $scope.modsecLoading = false; + + // $('#modsecurity_status').bootstrapToggle('off'); + // $('#SecAuditEngine').bootstrapToggle('off'); + // $('#SecRuleEngine').bootstrapToggle('off'); + $('#modsecurity_status').prop('checked', false); + $('#SecAuditEngine').prop('checked', false); + $('#SecRuleEngine').prop('checked', false); + + + url = "/firewall/fetchModSecSettings"; + + var phpSelection = $scope.phpSelection; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.modsecLoading = true; + + if (response.data.fetchStatus === 1) { + + if (response.data.installed === 1) { + + // if (response.data.modsecurity === 1) { + // $('#modsecurity_status').bootstrapToggle('on'); + // } + // if (response.data.SecAuditEngine === 1) { + // $('#SecAuditEngine').bootstrapToggle('on'); + // } + // if (response.data.SecRuleEngine === 1) { + // $('#SecRuleEngine').bootstrapToggle('on'); + // } + if (response.data.modsecurity === 1) { + $('#modsecurity_status').prop('checked', true); + } + + if (response.data.SecAuditEngine === 1) { + $('#SecAuditEngine').prop('checked', true); + } + + if (response.data.SecRuleEngine === 1) { + $('#SecRuleEngine').prop('checked', true); + } + + $scope.SecDebugLogLevel = response.data.SecDebugLogLevel; + $scope.SecAuditLogParts = response.data.SecAuditLogParts; + $scope.SecAuditLogRelevantStatus = response.data.SecAuditLogRelevantStatus; + $scope.SecAuditLogType = response.data.SecAuditLogType; + + } + + } + + } + + function cantLoadInitialDatas(response) { + $scope.modsecLoading = true; + } + + } + + + ///// + + /// Save ModSec Changes + + $scope.failedToSave = true; + $scope.successfullySaved = true; + + $scope.saveModSecConfigurations = function () { + + $scope.failedToSave = true; + $scope.successfullySaved = true; + $scope.modsecLoading = false; + $scope.couldNotConnect = true; + + + url = "/firewall/saveModSecConfigurations"; + + var data = { + modsecurity_status: modsecurity_status, + SecAuditEngine: SecAuditEngine, + SecRuleEngine: SecRuleEngine, + SecDebugLogLevel: $scope.SecDebugLogLevel, + SecAuditLogParts: $scope.SecAuditLogParts, + SecAuditLogRelevantStatus: $scope.SecAuditLogRelevantStatus, + SecAuditLogType: $scope.SecAuditLogType, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.saveStatus === 1) { + + $scope.failedToSave = true; + $scope.successfullySaved = false; + $scope.modsecLoading = true; + $scope.couldNotConnect = true; + + } else { + $scope.errorMessage = response.data.error_message; + + $scope.failedToSave = false; + $scope.successfullySaved = true; + $scope.modsecLoading = true; + $scope.couldNotConnect = true; + } + + } + + function cantLoadInitialDatas(response) { + $scope.failedToSave = true; + $scope.successfullySaved = false; + $scope.modsecLoading = true; + $scope.couldNotConnect = true; + } + + + }; + +}); +newapp.controller('modSecRulesPackV2', function ($scope, $http, $timeout, $window) { + + $scope.modsecLoading = true; + $scope.owaspDisable = true; + $scope.comodoDisable = true; + + + // + + $scope.installationQuote = true; + $scope.couldNotConnect = true; + $scope.installationFailed = true; + $scope.installationSuccess = true; + $scope.ruleFiles = true; + + ///// + + var owaspInstalled = false; + var comodoInstalled = false; + var counterOWASP = 0; + var counterComodo = 0; + + + $('#owaspInstalled').change(function () { + + owaspInstalled = $(this).prop('checked'); + $scope.ruleFiles = true; + + if (counterOWASP !== 0) { + if (owaspInstalled === true) { + installModSecRulesPack('installOWASP'); + } else { + installModSecRulesPack('disableOWASP') + } + } + + counterOWASP = counterOWASP + 1; + }); + + $('#comodoInstalled').change(function () { + + $scope.ruleFiles = true; + comodoInstalled = $(this).prop('checked'); + + if (counterComodo !== 0) { + + if (comodoInstalled === true) { + installModSecRulesPack('installComodo'); + } else { + installModSecRulesPack('disableComodo') + } + } + + counterComodo = counterComodo + 1; + + }); + + + getOWASPAndComodoStatus(true); + + function getOWASPAndComodoStatus(updateToggle) { + + $scope.modsecLoading = false; + + + url = "/firewall/getOWASPAndComodoStatus"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.modsecLoading = true; + + if (response.data.modSecInstalled === 1) { + + if (updateToggle === true) { + + // if (response.data.owaspInstalled === 1) { + // $('#owaspInstalled').bootstrapToggle('on'); + // $scope.owaspDisable = false; + // } else { + // $('#owaspInstalled').bootstrapToggle('off'); + // $scope.owaspDisable = true; + // } + // if (response.data.comodoInstalled === 1) { + // $('#comodoInstalled').bootstrapToggle('on'); + // $scope.comodoDisable = false; + // } else { + // $('#comodoInstalled').bootstrapToggle('off'); + // $scope.comodoDisable = true; + // } + if (response.data.owaspInstalled === 1) { + $('#owaspInstalled').prop('checked', true); + $scope.owaspDisable = false; + } else { + $('#owaspInstalled').prop('checked', false); + $scope.owaspDisable = true; + } + + if (response.data.comodoInstalled === 1) { + $('#comodoInstalled').prop('checked', true); + $scope.comodoDisable = false; + } else { + $('#comodoInstalled').prop('checked', false); + $scope.comodoDisable = true; + } + + } else { + + if (response.data.owaspInstalled === 1) { + $scope.owaspDisable = false; + } else { + $scope.owaspDisable = true; + } + if (response.data.comodoInstalled === 1) { + $scope.comodoDisable = false; + } else { + $scope.comodoDisable = true; + } + } + + } + + } + + function cantLoadInitialDatas(response) { + $scope.modsecLoading = true; + } + + } + + ///// + + function installModSecRulesPack(packName) { + + $scope.modsecLoading = false; + + url = "/firewall/installModSecRulesPack"; + + var data = { + packName: packName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.modsecLoading = true; + + if (response.data.installStatus === 1) { + + $scope.modsecLoading = true; + + // + + $scope.installationQuote = true; + $scope.couldNotConnect = true; + $scope.installationFailed = true; + $scope.installationSuccess = false; + + getOWASPAndComodoStatus(false); + + } else { + $scope.modsecLoading = true; + + // + + $scope.installationQuote = true; + $scope.couldNotConnect = true; + $scope.installationFailed = false; + $scope.installationSuccess = true; + + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + $scope.modsecLoading = true; + + // + + $scope.installationQuote = true; + $scope.couldNotConnect = false; + $scope.installationFailed = true; + $scope.installationSuccess = true; + } + + + } + + ///// + + $scope.fetchRulesFile = function (packName) { + + $scope.modsecLoading = false; + $scope.ruleFiles = false; + $scope.installationQuote = true; + $scope.couldNotConnect = true; + $scope.installationFailed = true; + $scope.installationSuccess = true; + + url = "/firewall/getRulesFiles"; + + var data = { + packName: packName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.modsecLoading = true; + + if (response.data.fetchStatus === 1) { + $scope.records = JSON.parse(response.data.data); + $scope.installationQuote = true; + $scope.couldNotConnect = true; + $scope.installationFailed = true; + $scope.installationSuccess = false; + + } else { + $scope.installationQuote = true; + $scope.couldNotConnect = true; + $scope.installationFailed = false; + $scope.installationSuccess = true; + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + $scope.modsecLoading = true; + $scope.installationQuote = true; + $scope.couldNotConnect = false; + $scope.installationFailed = true; + $scope.installationSuccess = true; + } + + }; + + + $scope.removeRuleFile = function (fileName, packName, status) { + + $scope.modsecLoading = false; + + + url = "/firewall/enableDisableRuleFile"; + + var data = { + packName: packName, + fileName: fileName, + status: status + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.modsecLoading = true; + + if (response.data.saveStatus === 1) { + + $scope.modsecLoading = true; + + // + + $scope.installationQuote = true; + $scope.couldNotConnect = true; + $scope.installationFailed = true; + $scope.installationSuccess = false; + + $scope.fetchRulesFile(packName); + + } else { + $scope.modsecLoading = true; + + // + + $scope.installationQuote = true; + $scope.couldNotConnect = true; + $scope.installationFailed = false; + $scope.installationSuccess = true; + + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + $scope.modsecLoading = true; + + // + + $scope.installationQuote = true; + $scope.couldNotConnect = false; + $scope.installationFailed = true; + $scope.installationSuccess = true; + } + + } + + +}); +newapp.controller('csfV2', function ($scope, $http, $timeout, $window) { + + $scope.csfLoading = true; + $scope.modeSecInstallBox = true; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + + $scope.installCSF = function () { + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + url = "/firewall/installCSF"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.installStatus === 1) { + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + getRequestStatus(); + + } else { + $scope.errorMessage = response.data.error_message; + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = true; + $scope.modsecLoading = true; + $scope.failedToStartInallation = false; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = false; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + } + + }; + + function getRequestStatus() { + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + url = "/firewall/installStatusCSF"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.abort === 0) { + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + $scope.requestData = response.data.requestStatus; + $timeout(getRequestStatus, 1000); + } else { + // Notifications + $timeout.cancel(); + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + + $scope.requestData = response.data.requestStatus; + + if (response.data.installed === 0) { + $scope.installationFailed = false; + $scope.errorMessage = response.data.error_message; + } else { + $scope.modSecSuccessfullyInstalled = false; + $timeout(function () { + $window.location.reload(); + }, 3000); + } + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = false; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + + } + + } + + + // After installation + + var currentMain = "generalLI"; + var currentChild = "general"; + + $scope.activateTab = function (newMain, newChild) { + $("#" + currentMain).removeClass("ui-tabs-active"); + $("#" + currentMain).removeClass("ui-state-active"); + + $("#" + newMain).addClass("ui-tabs-active"); + $("#" + newMain).addClass("ui-state-active"); + + $('#' + currentChild).hide(); + $('#' + newChild).show(); + + currentMain = newMain; + currentChild = newChild; + }; + + + $scope.removeCSF = function () { + + $scope.csfLoading = false; + + + url = "/firewall/removeCSF"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.csfLoading = true; + + + if (response.data.installStatus === 1) { + + new PNotify({ + title: 'Successfully removed!', + text: 'CSF successfully removed from server, refreshing page in 3 seconds..', + type: 'success' + }); + + $timeout(function () { + $window.location.reload(); + }, 3000); + + } else { + new PNotify({ + title: 'Operation failed!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + + new PNotify({ + title: 'Operation failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + }; + + //////// Fetch settings + + // + var testingMode = false; + var testingCounter = 0; + + + $('#testingMode').change(function () { + testingMode = $(this).prop('checked'); + + if (testingCounter !== 0) { + + if (testingMode === true) { + $scope.changeStatus('testingMode', 'enable'); + } else { + $scope.changeStatus('testingMode', 'disable'); + } + } + testingCounter = testingCounter + 1; + }); + // + + // + var firewallStatus = false; + var firewallCounter = 0; + + + $('#firewallStatus').change(function () { + firewallStatus = $(this).prop('checked'); + + if (firewallCounter !== 0) { + + if (firewallStatus === true) { + $scope.changeStatus('csf', 'enable'); + } else { + $scope.changeStatus('csf', 'disable'); + } + } + firewallCounter = firewallCounter + 1; + }); + // + + + $scope.fetchSettings = function () { + + $scope.csfLoading = false; + + // $('#testingMode').bootstrapToggle('off'); + // $('#firewallStatus').bootstrapToggle('off'); + $('#testingMode').prop('checked', false); + $('#firewallStatus').prop('checked', false); + + + url = "/firewall/fetchCSFSettings"; + + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.csfLoading = true; + + if (response.data.fetchStatus === 1) { + + new PNotify({ + title: 'Successfully fetched!', + text: 'CSF settings successfully fetched.', + type: 'success' + }); + + // if (response.data.testingMode === 1) { + // $('#testingMode').bootstrapToggle('on'); + // } + // if (response.data.firewallStatus === 1) { + // $('#firewallStatus').bootstrapToggle('on'); + // } + if (response.data.testingMode === 1) { + $('#testingMode').prop('checked', true); + } + if (response.data.firewallStatus === 1) { + $('#firewallStatus').prop('checked', true); + } + + + $scope.tcpIN = response.data.tcpIN; + $scope.tcpOUT = response.data.tcpOUT; + $scope.udpIN = response.data.udpIN; + $scope.udpOUT = response.data.udpOUT; + } else { + + new PNotify({ + title: 'Failed to load!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.csfLoading = true; + + new PNotify({ + title: 'Failed to load!', + text: 'Failed to fetch CSF settings.', + type: 'error' + }); + } + + }; + $scope.fetchSettings(); + + + $scope.changeStatus = function (controller, status) { + + $scope.csfLoading = false; + + + url = "/firewall/changeStatus"; + + + var data = { + controller: controller, + status: status + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.csfLoading = true; + + if (response.data.status === 1) { + + new PNotify({ + title: 'Success!', + text: 'Changes successfully applied.', + type: 'success' + }); + } else { + + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.csfLoading = true; + + new PNotify({ + title: 'Failed to load!', + text: 'Failed to fetch CSF settings.', + type: 'error' + }); + } + + }; + + $scope.modifyPorts = function (protocol) { + + $scope.csfLoading = false; + + var ports; + + if (protocol === 'TCP_IN') { + ports = $scope.tcpIN; + } else if (protocol === 'TCP_OUT') { + ports = $scope.tcpOUT; + } else if (protocol === 'UDP_IN') { + ports = $scope.udpIN; + } else if (protocol === 'UDP_OUT') { + ports = $scope.udpOUT; + } + + + url = "/firewall/modifyPorts"; + + + var data = { + protocol: protocol, + ports: ports + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.csfLoading = true; + + if (response.data.status === 1) { + + new PNotify({ + title: 'Success!', + text: 'Changes successfully applied.', + type: 'success' + }); + } else { + + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.csfLoading = true; + + new PNotify({ + title: 'Failed to load!', + text: 'Failed to fetch CSF settings.', + type: 'error' + }); + } + + }; + + $scope.modifyIPs = function (mode) { + + $scope.csfLoading = false; + + var ipAddress; + + if (mode === 'allowIP') { + ipAddress = $scope.allowIP; + } else if (mode === 'blockIP') { + ipAddress = $scope.blockIP; + } + + + url = "/firewall/modifyIPs"; + + + var data = { + mode: mode, + ipAddress: ipAddress + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.csfLoading = true; + + if (response.data.status === 1) { + + new PNotify({ + title: 'Success!', + text: 'Changes successfully applied.', + type: 'success' + }); + } else { + + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.csfLoading = true; + + new PNotify({ + title: 'Failed to load!', + text: 'Failed to fetch CSF settings.', + type: 'error' + }); + } + + }; + +}); + +newapp.controller('installImunifyV2', function ($scope, $http, $timeout, $window) { + + $scope.installDockerStatus = true; + $scope.installBoxGen = true; + $scope.dockerInstallBTN = false; + + $scope.submitinstallImunify = function () { + + $scope.installDockerStatus = false; + $scope.installBoxGen = true; + $scope.dockerInstallBTN = true; + + url = "/firewall/submitinstallImunify"; + + var data = { + key: $scope.key + }; + + 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) { + $scope.installBoxGen = false; + getRequestStatus(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + function getRequestStatus() { + $scope.installDockerStatus = false; + + url = "/serverstatus/switchTOLSWSStatus"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + if (response.data.abort === 0) { + $scope.requestData = response.data.requestStatus; + $timeout(getRequestStatus, 1000); + } else { + // Notifications + $scope.installDockerStatus = true; + $timeout.cancel(); + $scope.requestData = response.data.requestStatus; + if (response.data.installed === 1) { + $timeout(function () { + $window.location.reload(); + }, 3000); + } + + } + } + + function cantLoadInitialDatas(response) { + $scope.installDockerStatus = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + } +}); +newapp.controller('installImunifyAVV2', function ($scope, $http, $timeout, $window) { + + $scope.installDockerStatus = true; + $scope.installBoxGen = true; + $scope.dockerInstallBTN = false; + + $scope.submitinstallImunify = function () { + + $scope.installDockerStatus = false; + $scope.installBoxGen = true; + $scope.dockerInstallBTN = true; + + url = "/firewall/submitinstallImunifyAV"; + + var data = {}; + + 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) { + $scope.installBoxGen = false; + getRequestStatus(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + function getRequestStatus() { + $scope.installDockerStatus = false; + + url = "/serverstatus/switchTOLSWSStatus"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + if (response.data.abort === 0) { + $scope.requestData = response.data.requestStatus; + $timeout(getRequestStatus, 1000); + } else { + // Notifications + $scope.installDockerStatus = true; + $timeout.cancel(); + $scope.requestData = response.data.requestStatus; + if (response.data.installed === 1) { + $timeout(function () { + $window.location.reload(); + }, 3000); + } + + } + } + + function cantLoadInitialDatas(response) { + $scope.installDockerStatus = 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/firewall/templates/firewall/csfV2.html b/firewall/templates/firewall/csfV2.html new file mode 100644 index 000000000..e3ba34b46 --- /dev/null +++ b/firewall/templates/firewall/csfV2.html @@ -0,0 +1,253 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

CSF (ConfigServer Security and Firewall)!

+
+

On this page you can configure CSF (ConfigServer + Security and Firewall) settings.

+
+ {% if csfInstalled == 0 %} +
+
+

CSF

+ +
+
+

CSF is not installed

+
+
+
+ +
+
+
+
+
+
+

{% trans "Failed to start installation, Error message: " %} {$ errorMessage + $}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+

{% trans "Installation failed." %} {$ errorMessage $}

+
+
+

{% trans "CSF successfully installed, refreshing page in 3 seconds.." %}

+
+
+
+
+
+
+
+ +

In winter we must protect each other..

+ +
+
+ +
+
+
+
+ {% else %} +
+
    + {#
  • #} + {#
    #} + {#

    CSF

    #} + {# #} + {#
    #} + {#
  • #} +
  • General +
  • +
  • CSF
  • +
  • LDF
  • +
+
+
+
+
+
+
+

Remove CSF

+
+
+
+
+ +
+
+
+
+
+
+

Firewall

+
+
+ +
+
+
+
+

Testing Mode

+
+
+ +
+
+
+
+

TCP IN Ports

+
+
+ +
+
+ +
+
+
+
+

TCP Out Ports

+
+
+ +
+
+ +
+
+
+
+

UDP In Ports

+
+
+ +
+
+ +
+
+
+
+

UDP Out Ports

+
+
+ +
+
+ +
+
+
+
+
+ + + {% endif %} +
+{% endblock %} diff --git a/firewall/templates/firewall/firewallV2.html b/firewall/templates/firewall/firewallV2.html new file mode 100644 index 000000000..159720cd6 --- /dev/null +++ b/firewall/templates/firewall/firewallV2.html @@ -0,0 +1,130 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Add/Delete Firewall Rules

+

On this page you can add/delete firewall rules. (By + default all ports are blocked, except mentioned below)

+
+
+
+

Add/Delete Rules

+ +
+
+ +
+
+

{% trans "Action failed. Error message:" %} {$ errorMessage $}

+
+
+

{% trans "Action successful." %}

+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ ID + + Name + + Protocol + + IP Address + + Port + + Delete +
+ + + + + + +
+
+
+{% endblock %} diff --git a/firewall/templates/firewall/imunifyAVV2.html b/firewall/templates/firewall/imunifyAVV2.html new file mode 100644 index 000000000..218e6f428 --- /dev/null +++ b/firewall/templates/firewall/imunifyAVV2.html @@ -0,0 +1,80 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

ImunifyAV -

+ {% trans "Imunify Docs" %} +
+

Access ImunifyAV

+
+
+

ImunifyAV

+

ImunifyAV is now integrated via their new API. You can + manage Imunify by clicking below. You can use your server root credentials to access Imunify.

+ +
+
+
+

ImunifyAV Not working?

+ +
+

If for some reason ImunifyAV is not working, you can + re-install it using the form below.

+
+
+
+
+ +
+
+

We will run following commands again:

+
+

wget https://repo.imunify360.cloudlinux.com/defence360/imav-deploy.sh

+
+

bash imav-deploy.sh

+
+ +

If you can still not access ImunifyAV after re-installation, just run + the above commands on your server terminal.

+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+{% endblock %} diff --git a/firewall/templates/firewall/imunifyV2.html b/firewall/templates/firewall/imunifyV2.html new file mode 100644 index 000000000..99d5fa543 --- /dev/null +++ b/firewall/templates/firewall/imunifyV2.html @@ -0,0 +1,92 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Imunify -

+ {% trans "Imunify Docs" %} +
+

Access Imunify

+
+
+

Imunify

+

Imunify is now integrated via their new API. You can + manage Imunify by clicking below. You can use your server root credentials to access Imunify. Login + details for Imunify360 is your server root and its password.

+ +
+
+
+

Imunify360 Not working?

+ +
+

If for some reason Imunify360 is not working, you can + re-install it using the form below.

+
+
+
+
+ +
+
+

We will run following commands again:

+
+

wget https://repo.imunify360.cloudlinux.com/defence360/i360deploy.sh -O + i360deploy.sh

+
+

bash i360deploy.sh --key YOUR_KEY --yes

+
+ +

If you can still not access Imunify360 after re-installation, just run + the above commands on your server terminal, make sure to replace YOUR_KEY + with your + Imunify360 Key.

+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+

Imunify Key

+
+
+ +
+
+
+ +
+
+
+
+
+{% endblock %} diff --git a/firewall/templates/firewall/modSecurityRulesPacksV2.html b/firewall/templates/firewall/modSecurityRulesPacksV2.html new file mode 100644 index 000000000..a08e74f42 --- /dev/null +++ b/firewall/templates/firewall/modSecurityRulesPacksV2.html @@ -0,0 +1,131 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

ModSecurity Rules Packages! -

+ {% trans "ModSec Docs" %} +
+

Install/Un-install ModSecurity rules packages.

+
+
+
+

ModSecurity Rules Packages!

+ +
+
+ {% if modSecInstalled == 0 %} +
+

ModSecurity is not installed

+
+ + {% else %} +
+ + + + + + + + + + + + + + + +
+ Package + + Status + +
OWASP ModSecurity Core Rules +
+ +
+
+ +
+
+
+
+

{% trans "Operation successful." %}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+

{% trans "Operation failed, Error message: " %} {$ errorMessage $}

+
+
+

{% trans "Operation successful." %}

+
+
+
+ + + + + + + + + + + + + + + + + +
+ ID + + Supplier + + Filename + + Status +
+ +
+
+
+ {% endif %} +
+
+{% endblock %} diff --git a/firewall/templates/firewall/modSecurityRulesV2.html b/firewall/templates/firewall/modSecurityRulesV2.html new file mode 100644 index 000000000..90a8b8b71 --- /dev/null +++ b/firewall/templates/firewall/modSecurityRulesV2.html @@ -0,0 +1,69 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

ModSecurity Rules! -

+ {% trans "ModSec Docs" %} +
+

On this page you can add/delete ModSecurity rules.

+
+
+
+

ModSecurity Rules

+ +
+
+ {% if modSecInstalled == 1 %} +
+ +
+
+ +
+
+
+

{% trans "ModSecurity Rules Saved" %}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+

{% trans "Could not save rules, Error message: " %} {$ errorMessage $}

+
+
+ {% else %} +
+

ModSecurity is not installed

+
+ +
+ {% endif %} +
+
+{% endblock %} diff --git a/firewall/templates/firewall/modSecurityV2.html b/firewall/templates/firewall/modSecurityV2.html new file mode 100644 index 000000000..dd787c4f6 --- /dev/null +++ b/firewall/templates/firewall/modSecurityV2.html @@ -0,0 +1,381 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + {% if OLS %} +
+
+
+

ModSecurity Configurations! -

+ {% trans "ModSec Docs" %} +
+

On this page you can configure ModSecurity + settings.

+
+
+
+

ModSecurity

+ +
+
+ {% if modSecInstalled == 0 %} +
+

ModSecurity is not installed

+
+ +
+
+
+
+

{% trans "Failed to start installation, Error message: " %} {$ + errorMessage + $}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+

{% trans "Installation failed." %} {$ errorMessage $}

+
+
+

{% trans "ModSecurity successfully installed, refreshing page in 3 seconds.." %}

+
+
+
+
+
+
+
+

{% trans "Winter is coming, but so is ModSecurity." %} +

+
+
+ +
+
+
+ {% else %} +
+
+
+

ModSecurity Status

+
+
+ +
+
+
+
+

SecAuditEngine

+
+
+ +
+
+
+
+

SecRuleEngine

+
+
+ +
+
+
+
+

SecDebugLogLevel

+
+
+
+ {# {$ SecDebugLogLevel$}#} +
+
+
+
+
+

SecAuditLogParts

+
+
+ +
+
+
+
+

SecAuditLogRelevantStatus

+
+
+ +
+
+
+
+

SecAuditLogType

+
+
+ +
+
+
+ +
+
+
+
+

{% trans "Failed to save ModSecurity configurations. Error message: " %} + {$ errorMessage $}

+
+
+

{% trans "ModSecurity configurations successfully saved." %}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+
+
+
+ {% endif %} +
+
+ + {% else %} +
+
+
+

ModSecurity Configurations! -

+ {% trans "ModSec Docs" %} +
+

On this page you can configure ModSecurity + settings.

+
+
+
+

ModSecurity

+ +
+
+ {% if modSecInstalled == 0 %} +
+

ModSecurity is not installed

+
+ +
+
+
+
+

{% trans "Failed to start installation, Error message: " %} {$ + errorMessage + $}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+

{% trans "Installation failed." %} {$ errorMessage $}

+
+
+

{% trans "ModSecurity successfully installed, refreshing page in 3 seconds.." %}

+
+
+
+
+
+
+
+

{% trans "Winter is coming, but so is ModSecurity." %} +

+
+
+ +
+
+
+ {% else %} +
+
+
+

SecAuditEngine

+
+
+ +
+
+
+
+

SecRuleEngine

+
+
+ +
+
+
+
+

SecDebugLogLevel

+
+
+
+ {# {$ SecDebugLogLevel$}#} +
+
+
+
+
+

SecAuditLogParts

+
+
+ +
+
+
+
+

SecAuditLogRelevantStatus

+
+
+ +
+
+
+
+

SecAuditLogType

+
+
+ +
+
+
+ +
+
+
+
+

{% trans "Failed to save ModSecurity configurations. Error message: " %} + {$ errorMessage $}

+
+
+

{% trans "ModSecurity configurations successfully saved." %}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+
+
+
+ {% endif %} +
+
+ {% endif %} +{% endblock %} diff --git a/firewall/templates/firewall/notAvailableAVV2.html b/firewall/templates/firewall/notAvailableAVV2.html new file mode 100644 index 000000000..0c6765ac8 --- /dev/null +++ b/firewall/templates/firewall/notAvailableAVV2.html @@ -0,0 +1,58 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Not available -

+ {% trans "Imunify Docs" %} +
+

ImunifyAV is not installed

+
+
+
+
+
+
+

Activate Now

+ +
+

"Imunify is not installed, click to install + now.

+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+{% endblock %} diff --git a/firewall/templates/firewall/notAvailableV2.html b/firewall/templates/firewall/notAvailableV2.html new file mode 100644 index 000000000..a0936306d --- /dev/null +++ b/firewall/templates/firewall/notAvailableV2.html @@ -0,0 +1,78 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Not available -

+ {% trans "Imunify Docs" %} +
+

Either Imunify is not installed or you are not on + CloudLinux OS.

+
+ {% if not CL %} +
+

CloudLinux is not installed on your server. + Click + Herefor conversion details.

+ {% else %} +
+
+
+
+
+

Activate Now

+ +
+

"Imunify is not installed, click to install + now.

+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+

Imunify Key

+
+
+ +
+
+
+ +
+
+
+
+
+
+ {% endif %} +
+{% endblock %} diff --git a/firewall/templates/firewall/secureSSHV2.html b/firewall/templates/firewall/secureSSHV2.html new file mode 100644 index 000000000..0829fb716 --- /dev/null +++ b/firewall/templates/firewall/secureSSHV2.html @@ -0,0 +1,160 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Secure SSH -

+ {% trans "SSH Docs" %} +
+

Secure or harden SSH Configurations.

+
+
+

Secure SSH

+ +
+
+ +
+
+
+
+
+
+

SSH Port

+
+
+ +
+
+
+
+

Permit Root Login

+
+
+ +
+
+
+
+

+
+
+

{% trans "Before disabling root login, make sure you have another account with sudo priviliges on server." %}

+
+
+
+ +
+
+
+
+

{% trans "Error message: " %}{$ errorMessage $}

+
+
+

{% trans "SSH Configurations Saved." %}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+
+
+
+
+ +
+
+{% endblock %} diff --git a/firewall/urls.py b/firewall/urls.py index ed912364a..b0d9a1592 100755 --- a/firewall/urls.py +++ b/firewall/urls.py @@ -4,11 +4,11 @@ from . import views urlpatterns = [ url(r'^securityHome', views.securityHome, name='securityHome'), url(r'^$', views.firewallHome, name='firewallHome'), + url(r'^V2/V2$', views.firewallHomeV2, name='firewallHomeV2'), url(r'^getCurrentRules', views.getCurrentRules, name='getCurrentRules'), url(r'^addRule', views.addRule, name='addRule'), url(r'^deleteRule', views.deleteRule, name='deleteRule'), - url(r'^reloadFirewall', views.reloadFirewall, name='reloadFirewall'), url(r'^stopFirewall', views.stopFirewall, name='stopFirewall'), url(r'^startFirewall', views.startFirewall, name='startFirewall'), @@ -17,23 +17,26 @@ urlpatterns = [ ## secure SSH url(r'^secureSSH', views.secureSSH, name='secureSSH'), + url(r'^V2/secureSSHV2', views.secureSSHV2, name='secureSSHV2'), url(r'^getSSHConfigs', views.getSSHConfigs, name='getSSHConfigs'), url(r'^saveSSHConfigs', views.saveSSHConfigs, name='saveSSHConfigs'), url(r'^deleteSSHKey', views.deleteSSHKey, name='deleteSSHKey'), url(r'^addSSHKey', views.addSSHKey, name='addSSHKey'), - ## ModSecurity url(r'^modSecurity$', views.loadModSecurityHome, name='modSecurity'), + url(r'^V2/modSecurityV2$', views.loadModSecurityHomeV2, name='modSecurityV2'), url(r'^installModSec$', views.installModSec, name='installModSec'), url(r'^installStatusModSec$', views.installStatusModSec, name='installStatusModSec'), url(r'^fetchModSecSettings$', views.fetchModSecSettings, name='fetchModSecSettings'), url(r'^saveModSecConfigurations$', views.saveModSecConfigurations, name='saveModSecConfigurations'), url(r'^modSecRules$', views.modSecRules, name='modSecRules'), + url(r'^V2/modSecRulesV2$', views.modSecRulesV2, name='modSecRulesV2'), url(r'^fetchModSecRules$', views.fetchModSecRules, name='fetchModSecRules'), url(r'^saveModSecRules$', views.saveModSecRules, name='saveModSecRules'), url(r'^modSecRulesPacks$', views.modSecRulesPacks, name='modSecRulesPacks'), + url(r'^V2/modSecRulesPacksV2$', views.modSecRulesPacksV2, name='modSecRulesPacksV2'), url(r'^getOWASPAndComodoStatus$', views.getOWASPAndComodoStatus, name='getOWASPAndComodoStatus'), url(r'^installModSecRulesPack$', views.installModSecRulesPack, name='installModSecRulesPack'), url(r'^getRulesFiles$', views.getRulesFiles, name='getRulesFiles'), @@ -42,6 +45,7 @@ urlpatterns = [ ## CSF url(r'^csf$', views.csf, name='csf'), + url(r'^V2/csfV2$', views.csfV2, name='csfV2'), url(r'^installCSF$', views.installCSF, name='installCSF'), url(r'^installStatusCSF$', views.installStatusCSF, name='installStatusCSF'), url(r'^removeCSF$', views.removeCSF, name='removeCSF'), @@ -54,14 +58,13 @@ urlpatterns = [ ## Imunify url(r'^imunify$', views.imunify, name='imunify'), + url(r'^V2/imunifyV2$', views.imunifyV2, name='imunifyV2'), url(r'^submitinstallImunify$', views.submitinstallImunify, name='submitinstallImunify'), ## ImunifyAV url(r'^imunifyAV$', views.imunifyAV, name='imunifyAV'), + url(r'^V2/imunifyAVV2$', views.imunifyAVV2, name='imunifyAVV2'), url(r'^submitinstallImunifyAV$', views.submitinstallImunifyAV, name='submitinstallImunifyAV'), - - - -] \ No newline at end of file +] diff --git a/firewall/views.py b/firewall/views.py index a1b342d62..6993c413f 100755 --- a/firewall/views.py +++ b/firewall/views.py @@ -3,6 +3,8 @@ import json from loginSystem.views import loadLoginPage from .firewallManager import FirewallManager from .pluginManager import pluginManager + + # Create your views here. @@ -14,6 +16,7 @@ def securityHome(request): except KeyError: return redirect(loadLoginPage) + def firewallHome(request): try: userID = request.session['userID'] @@ -32,6 +35,26 @@ def firewallHome(request): except KeyError: return redirect(loadLoginPage) + +def firewallHomeV2(request): + try: + userID = request.session['userID'] + + result = pluginManager.preFirewallHome(request) + if result != 200: + return result + fm = FirewallManager() + coreResult = fm.firewallHomeV2(request, userID) + + result = pluginManager.postFirewallHome(request, coreResult) + if result != 200: + return result + + return coreResult + except KeyError: + return redirect(loadLoginPage) + + def getCurrentRules(request): try: userID = request.session['userID'] @@ -40,6 +63,7 @@ def getCurrentRules(request): except KeyError: return redirect(loadLoginPage) + def addRule(request): try: userID = request.session['userID'] @@ -59,6 +83,7 @@ def addRule(request): except KeyError: return redirect(loadLoginPage) + def deleteRule(request): try: userID = request.session['userID'] @@ -78,6 +103,7 @@ def deleteRule(request): except KeyError: return redirect(loadLoginPage) + def reloadFirewall(request): try: userID = request.session['userID'] @@ -97,6 +123,7 @@ def reloadFirewall(request): except KeyError: return redirect(loadLoginPage) + def startFirewall(request): try: userID = request.session['userID'] @@ -116,6 +143,7 @@ def startFirewall(request): except KeyError: return redirect(loadLoginPage) + def stopFirewall(request): try: userID = request.session['userID'] @@ -124,7 +152,6 @@ def stopFirewall(request): if result != 200: return result - fm = FirewallManager() coreResult = fm.stopFirewall(userID) @@ -136,6 +163,7 @@ def stopFirewall(request): except KeyError: return redirect(loadLoginPage) + def firewallStatus(request): try: userID = request.session['userID'] @@ -155,6 +183,7 @@ def firewallStatus(request): except KeyError: return redirect(loadLoginPage) + def secureSSH(request): try: userID = request.session['userID'] @@ -174,6 +203,27 @@ def secureSSH(request): except KeyError: return redirect(loadLoginPage) + +def secureSSHV2(request): + try: + userID = request.session['userID'] + + result = pluginManager.preSecureSSH(request) + if result != 200: + return result + + fm = FirewallManager() + coreResult = fm.secureSSHV2(request, userID) + + result = pluginManager.postSecureSSH(request, coreResult) + if result != 200: + return result + + return coreResult + except KeyError: + return redirect(loadLoginPage) + + def getSSHConfigs(request): try: userID = request.session['userID'] @@ -182,6 +232,7 @@ def getSSHConfigs(request): except KeyError: return redirect(loadLoginPage) + def saveSSHConfigs(request): try: userID = request.session['userID'] @@ -201,6 +252,7 @@ def saveSSHConfigs(request): except KeyError: return redirect(loadLoginPage) + def deleteSSHKey(request): try: userID = request.session['userID'] @@ -219,6 +271,7 @@ def deleteSSHKey(request): except KeyError: return redirect(loadLoginPage) + def addSSHKey(request): try: userID = request.session['userID'] @@ -238,6 +291,7 @@ def addSSHKey(request): except KeyError: return redirect(loadLoginPage) + def loadModSecurityHome(request): try: userID = request.session['userID'] @@ -257,6 +311,27 @@ def loadModSecurityHome(request): except KeyError: return redirect(loadLoginPage) + +def loadModSecurityHomeV2(request): + try: + userID = request.session['userID'] + + result = pluginManager.preLoadModSecurityHome(request) + if result != 200: + return result + + fm = FirewallManager() + coreResult = fm.loadModSecurityHomeV2(request, userID) + + result = pluginManager.postLoadModSecurityHome(request, coreResult) + if result != 200: + return result + + return coreResult + except KeyError: + return redirect(loadLoginPage) + + def installModSec(request): try: userID = request.session['userID'] @@ -265,6 +340,7 @@ def installModSec(request): except KeyError: return redirect(loadLoginPage) + def installStatusModSec(request): try: userID = request.session['userID'] @@ -273,6 +349,7 @@ def installStatusModSec(request): except KeyError: return redirect(loadLoginPage) + def fetchModSecSettings(request): try: userID = request.session['userID'] @@ -281,6 +358,7 @@ def fetchModSecSettings(request): except KeyError: return redirect(loadLoginPage) + def saveModSecConfigurations(request): try: userID = request.session['userID'] @@ -300,6 +378,7 @@ def saveModSecConfigurations(request): except KeyError: return redirect(loadLoginPage) + def modSecRules(request): try: userID = request.session['userID'] @@ -319,6 +398,27 @@ def modSecRules(request): except KeyError: return redirect(loadLoginPage) + +def modSecRulesV2(request): + try: + userID = request.session['userID'] + + result = pluginManager.preModSecRules(request) + if result != 200: + return result + + fm = FirewallManager() + coreResult = fm.modSecRulesV2(request, userID) + + result = pluginManager.postModSecRules(request, coreResult) + if result != 200: + return result + + return coreResult + except KeyError: + return redirect(loadLoginPage) + + def fetchModSecRules(request): try: userID = request.session['userID'] @@ -327,6 +427,7 @@ def fetchModSecRules(request): except KeyError: return redirect(loadLoginPage) + def saveModSecRules(request): try: userID = request.session['userID'] @@ -346,6 +447,7 @@ def saveModSecRules(request): except KeyError: return redirect(loadLoginPage) + def modSecRulesPacks(request): try: userID = request.session['userID'] @@ -365,6 +467,27 @@ def modSecRulesPacks(request): except KeyError: return redirect(loadLoginPage) + +def modSecRulesPacksV2(request): + try: + userID = request.session['userID'] + + result = pluginManager.preModSecRulesPacks(request) + if result != 200: + return result + + fm = FirewallManager() + coreResult = fm.modSecRulesPacksV2(request, userID) + + result = pluginManager.postModSecRulesPacks(request, coreResult) + if result != 200: + return result + + return coreResult + except KeyError: + return redirect(loadLoginPage) + + def getOWASPAndComodoStatus(request): try: userID = request.session['userID'] @@ -384,6 +507,7 @@ def getOWASPAndComodoStatus(request): except KeyError: return redirect(loadLoginPage) + def installModSecRulesPack(request): try: userID = request.session['userID'] @@ -403,6 +527,7 @@ def installModSecRulesPack(request): except KeyError: return redirect(loadLoginPage) + def getRulesFiles(request): try: userID = request.session['userID'] @@ -422,6 +547,7 @@ def getRulesFiles(request): except KeyError: return redirect(loadLoginPage) + def enableDisableRuleFile(request): try: userID = request.session['userID'] @@ -441,6 +567,7 @@ def enableDisableRuleFile(request): except KeyError: return redirect(loadLoginPage) + def csf(request): try: @@ -459,6 +586,26 @@ def csf(request): except KeyError: return redirect(loadLoginPage) + +def csfV2(request): + try: + + result = pluginManager.preCSF(request) + if result != 200: + return result + + fm = FirewallManager(request) + coreResult = fm.csfV2() + + result = pluginManager.postCSF(request, coreResult) + if result != 200: + return result + + return coreResult + except KeyError: + return redirect(loadLoginPage) + + def installCSF(request): try: fm = FirewallManager(request) @@ -466,6 +613,7 @@ def installCSF(request): except KeyError: return redirect(loadLoginPage) + def installStatusCSF(request): try: fm = FirewallManager(request) @@ -473,6 +621,7 @@ def installStatusCSF(request): except KeyError: return redirect(loadLoginPage) + def removeCSF(request): try: fm = FirewallManager(request) @@ -480,6 +629,7 @@ def removeCSF(request): except KeyError: return redirect(loadLoginPage) + def fetchCSFSettings(request): try: fm = FirewallManager(request) @@ -487,6 +637,7 @@ def fetchCSFSettings(request): except KeyError: return redirect(loadLoginPage) + def changeStatus(request): try: @@ -505,6 +656,7 @@ def changeStatus(request): except KeyError: return redirect(loadLoginPage) + def modifyPorts(request): try: @@ -523,6 +675,7 @@ def modifyPorts(request): except KeyError: return redirect(loadLoginPage) + def modifyIPs(request): try: @@ -541,6 +694,7 @@ def modifyIPs(request): except KeyError: return redirect(loadLoginPage) + ## Imunify def imunify(request): @@ -552,6 +706,17 @@ def imunify(request): except KeyError: return redirect(loadLoginPage) + +def imunifyV2(request): + try: + + fm = FirewallManager(request) + return fm.imunifyV2() + + except KeyError: + return redirect(loadLoginPage) + + def submitinstallImunify(request): try: @@ -561,6 +726,7 @@ def submitinstallImunify(request): except KeyError: return redirect(loadLoginPage) + ## ImunifyAV def imunifyAV(request): @@ -572,6 +738,17 @@ def imunifyAV(request): except KeyError: return redirect(loadLoginPage) + +def imunifyAVV2(request): + try: + + fm = FirewallManager(request) + return fm.imunifyAVV2() + + except KeyError: + return redirect(loadLoginPage) + + def submitinstallImunifyAV(request): try: diff --git a/mailServer/templates/mailServer/listEmailsV2.html b/mailServer/templates/mailServer/listEmailsV2.html index fdb87ac27..8966247f5 100644 --- a/mailServer/templates/mailServer/listEmailsV2.html +++ b/mailServer/templates/mailServer/listEmailsV2.html @@ -17,7 +17,7 @@
diff --git a/managePHP/static/managePHP/managePHPV2.js b/managePHP/static/managePHP/managePHPV2.js new file mode 100644 index 000000000..d51835de1 --- /dev/null +++ b/managePHP/static/managePHP/managePHPV2.js @@ -0,0 +1,654 @@ +function GLobalAjaxCall(http, url, data, successCallBack, failureCallBack) { + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + http.post(url, data, config).then(successCallBack, failureCallBack); +} + +function GlobalRespSuccess(response) { + globalScope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Successfully executed.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } +} +function GlobalRespFailed(response) { + globalScope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); +} + +newapp.controller('installExtensionsV2', function ($scope, $http, $timeout) { + + + var size = 0; + var extName = ''; + + $scope.availableExtensions = true; + $scope.loadingExtensions = true; + $scope.canNotFetch = true; + $scope.couldNotConnect = true; + $scope.phpSelectionDisabled = false; + $scope.request = true; + $scope.canNotPerform = true; + $scope.goback = true; + + $scope.fetchPHPDetails = function () { + $scope.loadingExtensions = false; + $scope.phpSelectionDisabled = false; + populateCurrentRecords(); + $scope.request = true; + }; + + $scope.installExt = function (extensionName) { + + extName = extensionName; + + $scope.phpSelectionDisabled = true; + $scope.requestData = ""; + + $scope.loadingExtensions = false; + $scope.availableExtensions = true; + $scope.request = false; + $scope.goback = true; + + url = "/managephp/submitExtensionRequest"; + + var data = { + extensionName: extensionName, + type: "install" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.extensionRequestStatus === 1) { + + getRequestStatus(); + $scope.canNotPerform = true; + + + } else { + $scope.canNotPerform = false; + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.canNotFetch = true; + $scope.couldNotConnect = false; + $scope.canNotPerform = true; + + + } + + + }; + + $scope.uninstallExt = function (extensionName) { + + extName = extensionName; + + $scope.phpSelectionDisabled = true; + $scope.requestData = ""; + $scope.goback = true; + + $scope.loadingExtensions = false; + $scope.availableExtensions = true; + $scope.request = false; + + url = "/managephp/submitExtensionRequest"; + + var data = { + extensionName: extensionName, + type: "uninstall" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.extensionRequestStatus == 1) { + + getRequestStatus(); + $scope.canNotPerform = true; + + + } else { + $scope.canNotPerform = false; + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.canNotFetch = true; + $scope.couldNotConnect = false; + $scope.canNotPerform = true; + + + } + + + }; + + function populateCurrentRecords() { + + var phpSelection = $scope.phpSelection; + + var queryString = window.location.search; + var searchParams = new URLSearchParams(queryString); + + var param3Value = searchParams.get('apache'); + if (param3Value === null) { + url = "/managephp/getExtensionsInformation"; + console.log('Nothing found') + } else { + url = "/managephp/getExtensionsInformation?apache=apache"; + } + + var data = { + phpSelection: phpSelection, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetchStatus === 1) { + + $scope.records = JSON.parse(response.data.data); + + $scope.availableExtensions = false; + $scope.loadingExtensions = true; + + $scope.canNotFetch = true; + $scope.couldNotConnect = true; + + + } else { + $scope.errorMessage = response.data.error_message; + $scope.canNotFetch = false; + $scope.couldNotConnect = true; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.canNotFetch = true; + $scope.couldNotConnect = false; + + + } + + } + + function getRequestStatus() { + + + url = "/managephp/getRequestStatus"; + + var data = { + size: size, + extensionName: extName, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.extensionRequestStatus === 1) { + + if (response.data.finished === 1) { + + $scope.loadingExtensions = true; + $scope.phpSelectionDisabled = false; + $scope.requestData = response.data.requestStatus; + $scope.goback = false; + $timeout.cancel(); + + } else { + size = Number(response.data.size); + $scope.requestData = response.data.requestStatus; + $timeout(getRequestStatus, 1000); + } + + + } else { + + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.canNotFetch = true; + $scope.couldNotConnect = false; + + + } + + + } + + +}); +newapp.controller('editPHPConfigV2', function ($scope, $http, $timeout) { + + $scope.loadingPHP = true; + $scope.cyberPanelLoading = true; + $scope.canNotFetch = true; + $scope.phpDetailsBox = true; + $scope.couldNotConnect = true; + $scope.detailsSaved = true; + $scope.savebtn = true; + $scope.configDataView = true; + $scope.canNotFetchAdvanced = true; + $scope.detailsSavedAdvanced = true; + $scope.savebtnAdvance = true; + + var allow_url_fopen = false; + var display_errors = false; + var file_uploads = false; + var allow_url_include = false; + + + $('#allow_url_fopen').change(function () { + allow_url_fopen = $(this).prop('checked'); + }); + + $('#display_errors').change(function () { + display_errors = $(this).prop('checked'); + }); + + + $('#file_uploads').change(function () { + file_uploads = $(this).prop('checked'); + }); + + $('#allow_url_include').change(function () { + allow_url_include = $(this).prop('checked'); + }); + + + $scope.fetchPHPDetails = function () { + var phpSelection = $scope.phpSelection; + if (!phpSelection) { + return; + } + + $scope.loadingPHP = false; + $scope.canNotFetch = true; + $scope.detailsSaved = true; + + + // $('#allow_url_fopen').bootstrapToggle('off'); + // $('#display_errors').bootstrapToggle('off'); + // $('#file_uploads').bootstrapToggle('off'); + // $('#allow_url_include').bootstrapToggle('off'); + $('#allow_url_fopen').prop('checked', false); + $('#display_errors').prop('checked', false); + $('#file_uploads').prop('checked', false); + $('#allow_url_include').prop('checked', false); + + + var queryString = window.location.search; + var searchParams = new URLSearchParams(queryString); + + var param3Value = searchParams.get('apache'); + if (param3Value === null) { + url = "/managephp/getCurrentPHPConfig"; + console.log('Nothing found') + } else { + url = "/managephp/getCurrentPHPConfig?apache=apache"; + } + + var data = { + phpSelection: phpSelection, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetchStatus == 1) { + + $scope.savebtn = false; + + + // if (response.data.allow_url_fopen === "1") { + // $('#allow_url_fopen').bootstrapToggle('on'); + // } + // if (response.data.display_errors === "1") { + // $('#display_errors').bootstrapToggle('on'); + // } + // if (response.data.file_uploads === "1") { + // $('#file_uploads').bootstrapToggle('on'); + // } + // if (response.data.allow_url_include === "1") { + // $('#allow_url_include').bootstrapToggle('on'); + // } + if (response.data.allow_url_fopen === "1") { + $('#allow_url_fopen').prop('checked', true); + } + if (response.data.display_errors === "1") { + $('#display_errors').prop('checked', true); + } + if (response.data.file_uploads === "1") { + $('#file_uploads').prop('checked', true); + } + if (response.data.allow_url_include === "1") { + $('#allow_url_include').prop('checked', true); + } + + + $scope.loadingPHP = true; + + $scope.memory_limit = response.data.memory_limit; + $scope.max_execution_time = response.data.max_execution_time; + $scope.upload_max_filesize = response.data.upload_max_filesize; + $scope.max_input_time = response.data.max_input_time; + $scope.post_max_size = response.data.post_max_size; + + $scope.phpDetailsBox = false; + + + } else { + + $scope.errorMessage = response.data.error_message; + $scope.canNotFetch = false; + $scope.loadingPHP = true; + $scope.phpDetailsBox = true; + } + + } + + function cantLoadInitialDatas(response) { + + + $scope.couldNotConnect = false; + + + } + + }; + + $scope.saveChanges = function () { + + $scope.loadingPHP = false; + + var phpSelection = $scope.phpSelection; + + var queryString = window.location.search; + var searchParams = new URLSearchParams(queryString); + + var param3Value = searchParams.get('apache'); + if (param3Value === null) { + url = "/managephp/savePHPConfigBasic"; + console.log('Nothing found') + } else { + url = "/managephp/savePHPConfigBasic?apache=apache"; + } + + var data = { + phpSelection: phpSelection, + allow_url_fopen: allow_url_fopen, + display_errors: display_errors, + file_uploads: file_uploads, + allow_url_include: allow_url_include, + memory_limit: $scope.memory_limit, + max_execution_time: $scope.max_execution_time, + upload_max_filesize: $scope.upload_max_filesize, + max_input_time: $scope.max_input_time, + post_max_size: $scope.post_max_size, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.saveStatus === 1) { + + $scope.detailsSaved = false; + $scope.loadingPHP = true; + + } else { + $scope.errorMessage = response.data.error_message; + $scope.canNotFetch = false; + $scope.couldNotConnect = true; + $scope.loadingPHP = true; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.canNotFetch = true; + $scope.couldNotConnect = false; + $scope.loadingPHP = true; + + + } + + + }; + + $scope.fetchAdvancePHPDetails = function () { + var phpSelection = $scope.phpSelection; + if (!phpSelection) { + return; + } + + $scope.loadingPHP = false; + $scope.savebtnAdvance = true; + + var queryString = window.location.search; + var searchParams = new URLSearchParams(queryString); + + var param3Value = searchParams.get('apache'); + if (param3Value === null) { + url = "/managephp/getCurrentAdvancedPHPConfig"; + console.log('Nothing found') + } else { + url = "/managephp/getCurrentAdvancedPHPConfig?apache=apache"; + } + + var data = { + phpSelection: phpSelection, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetchStatus == 1) { + + $scope.configDataView = false; + $scope.configData = response.data.configData; + $scope.loadingPHP = true; + + $scope.canNotFetchAdvanced = true; + $scope.detailsSavedAdvanced = true; + $scope.savebtnAdvance = false; + + + } else { + $scope.canNotFetchAdvanced = false; + $scope.detailsSavedAdvanced = true; + $scope.loadingPHP = true; + + $scope.errorMessage = response.data.error_message; + $scope.configDataView = true; + + } + + } + + function cantLoadInitialDatas(response) { + + + $scope.couldNotConnect = false; + $scope.loadingPHP = true; + + + } + + }; + + $scope.saveChangesAdvance = function () { + + $scope.loadingPHP = false; + + var phpSelection = $scope.phpSelection; + + var queryString = window.location.search; + var searchParams = new URLSearchParams(queryString); + + var param3Value = searchParams.get('apache'); + if (param3Value === null) { + url = "/managephp/savePHPConfigAdvance"; + console.log('Nothing found') + } else { + url = "/managephp/savePHPConfigAdvance?apache=apache"; + } + + + var data = { + phpSelection: phpSelection, + configData: $scope.configData, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.saveStatus == 1) { + + $scope.detailsSavedAdvanced = false; + $scope.loadingPHP = true; + + } else { + $scope.errorMessage = response.data.error_message; + $scope.canNotFetchAdvanced = false; + $scope.couldNotConnect = true; + $scope.loadingPHP = true; + } + + } + + function cantLoadInitialDatas(response) { + $scope.couldNotConnect = false; + $scope.canNotFetchAdvanced = true; + $scope.couldNotConnect = true; + $scope.loadingPHP = true; + + + } + + + }; + + $scope.restartPHP = function () { + + globalScope = $scope; + $scope.cyberPanelLoading = false; + url = "/managephp/restartPHP"; + var data = {}; + GLobalAjaxCall($http, url, data, GlobalRespSuccess, GlobalRespFailed); + + }; + + +}); diff --git a/managePHP/templates/managePHP/editPHPConfigV2.html b/managePHP/templates/managePHP/editPHPConfigV2.html new file mode 100644 index 000000000..5d398acf8 --- /dev/null +++ b/managePHP/templates/managePHP/editPHPConfigV2.html @@ -0,0 +1,223 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Edit PHP Configurations

+
+

Edit PHP Configurations on this page.

+
+
+

Edit PHP Configurations

+
+ - {% if apache %} + Edit Apache Configurations{% endif %} +
+
+
+ +
+
+
+
+
+
+

Select PHP

+
+
+ +
+
+ +
+
+
+
+

display_errors

+
+
+ +
+
+
+
+

file_uploads

+
+
+ +
+
+
+
+

allow_url_fopen

+
+
+ +
+
+
+
+

allow_url_include

+
+
+ +
+
+
+
+
+
+

memory_limit

+
+
+ +
+
+
+
+

max_execution_time

+
+
+ +
+
+
+
+

upload_max_filesize

+
+
+ +
+
+
+
+

post_max_size

+
+
+ +
+
+
+
+

max_input_time

+
+
+ +
+
+
+ + +
+
+
+
+

{% trans "Error message: " %}{$ errorMessage $}

+
+
+

{% trans "PHP Configs Saved." %}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+ +
+
+{% endblock %} diff --git a/managePHP/templates/managePHP/installExtensionsV2.html b/managePHP/templates/managePHP/installExtensionsV2.html new file mode 100644 index 000000000..f255a9a58 --- /dev/null +++ b/managePHP/templates/managePHP/installExtensionsV2.html @@ -0,0 +1,139 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

Install PHP Extensions -

+
+ {% if apache %} + Manage Apache Extensions + {% endif %} +
+
+
+

Install/uninstall php extensions on this page. +

+
+

Select PHP Version

+ +
+
+
+
+
+

Select PHP

+
+
+ +
+
+
+
+
+ + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ ID + + PHP + + Extension Name + + Description + + Status + + Install + + Uninstall +
+ + + + + + + + +
+
+
+
+ + +
+
+ + +
+
+

{% trans "Cannot fetch details. Error message:" %} {$ errorMessage $}

+
+
+

{% trans "Cannot perform operation. Error message:" %} {$ errorMessage $}

+
+
+

{% trans "Could not connect. Please refresh this page." %}

+
+
+ + +
+
+{% endblock %} diff --git a/managePHP/urls.py b/managePHP/urls.py index 1b9cafc46..95ff3766b 100755 --- a/managePHP/urls.py +++ b/managePHP/urls.py @@ -4,15 +4,16 @@ from . import views urlpatterns = [ url(r'^$', views.loadPHPHome, name='loadPHPHome'), url(r'^installExtensions', views.installExtensions, name='installExtensions'), + url(r'^V2/installExtensionsV2', views.installExtensionsV2, name='installExtensionsV2'), url(r'^getExtensionsInformation', views.getExtensionsInformation, name='getExtensionsInformation'), url(r'^submitExtensionRequest', views.submitExtensionRequest, name='submitExtensionRequest'), url(r'^getRequestStatus', views.getRequestStatus, name='getRequestStatus'), url(r'^editPHPConfigs', views.editPHPConfigs, name='editPHPConfigs'), + url(r'^V2/editPHPConfigsV2', views.editPHPConfigsV2, name='editPHPConfigsV2'), url(r'^getCurrentPHPConfig', views.getCurrentPHPConfig, name='getCurrentPHPConfig'), url(r'^savePHPConfigBasic', views.savePHPConfigBasic, name='savePHPConfigBasic'), url(r'^getCurrentAdvancedPHPConfig', views.getCurrentAdvancedPHPConfig, name='getCurrentAdvancedPHPConfig'), url(r'^savePHPConfigAdvance', views.savePHPConfigAdvance, name='savePHPConfigAdvance'), url(r'^restartPHP', views.restartPHP, name='restartPHP'), - -] \ No newline at end of file +] diff --git a/managePHP/views.py b/managePHP/views.py index 1816f029b..523d3676c 100755 --- a/managePHP/views.py +++ b/managePHP/views.py @@ -38,6 +38,7 @@ def loadPHPHome(request): except KeyError: return redirect(loadLoginPage) + def installExtensions(request): try: @@ -233,7 +234,6 @@ def installExtensions(request): ## non-active packages - phpExtension = installedPackages(phpVers=php53, extensionName="lsphp53-debuginfo", description="Debug information for package lsphp53", @@ -489,6 +489,1242 @@ def installExtensions(request): ## non-active packages + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-debuginfo", + description="Debug information for package lsphp54", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-mysql56-debuginfo", + description="Debug information for package lsphp54-mysql56", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-lsphp53-devel", + description="Files needed for building PHP extensions", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-mysql56", + description="PHP scripting language for creating dynamic web sites", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-mysqlnd", + description="A module for PHP applications that use MySQL databases", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-opcache", + description="The Zend OPcache", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-pecl-apc-devel", + description="APC developer files (header)", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-pecl-apc-panel", + description="APC control panel", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-sqlite", + description="Extension for the SQLite V2 Embeddable SQL Database Engine", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-xcache", + description="PHP accelerator, optimizer, encoder and dynamic content cacher", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-xcache-admin", + description="XCache Administration", + status=0) + + phpExtension.save() + + ### ################ ################# + + ##### Gather php 55 information + + ### ################ ################# + + php55 = PHP.objects.get(phpVers="php55") + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-bcmath", + description="A module for PHP applications for using the bcmath library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-common", + description="Common files for PHP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-dba", + description="A database abstraction layer module for PHP applications", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-enchant", + description="Human Language and Character Encoding Support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-gd", + description="A module for PHP applications for using the gd graphics library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-imap", + description="A module for PHP applications that use IMAP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-intl", + description="Internationalization extension for PHP application", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-ioncube-loader", + description="Ioncube Loader", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-ldap", + description="A module for PHP applications that use LDAP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-mbstring", + description="A module for PHP applications which need multi-byte string handling", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-mcrypt", + description="Standard PHP module provides mcrypt library support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-mysql", + description="A module for PHP applications that use MySQL databases", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-odbc", + description="A module for PHP applications that use ODBC databases", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-pdo", + description="A database access abstraction module for PHP applications", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-pear", + description="PHP Extension and Application Repository framework", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-pgsql", + description="A PostgreSQL database module for PHP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-process", + description="Modules for PHP script using system process interfaces", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-pspell", + description="A module for PHP applications for using pspell interfaces", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-recode", + description="A module for PHP applications for using the recode library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-snmp", + description="A module for PHP applications that query SNMP-managed devices", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-soap", + description="A module for PHP applications that use the SOAP protocol", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-tidy", + description="Standard PHP module provides tidy library support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-xml", + description="A module for PHP applications which use XML", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-xmlrpc", + description="A module for PHP applications which use the XML-RPC protocol", + status=1) + + phpExtension.save() + + ## non-active packages + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-debuginfo", + description="Debug information for package lsphp55", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-mysql56-debuginfo", + description="Debug information for package lsphp55-mysql56", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-lsphp53-devel", + description="Files needed for building PHP extensions", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp55-mysql56", + description="PHP scripting language for creating dynamic web sites", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-mysqlnd", + description="A module for PHP applications that use MySQL databases", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-opcache", + description="The Zend OPcache", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-sqlite", + description="Extension for the SQLite V2 Embeddable SQL Database Engine", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-xcache", + description="PHP accelerator, optimizer, encoder and dynamic content cacher", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp55-xcache-admin", + description="XCache Administration", + status=0) + + phpExtension.save() + + ### ################ ################# + + ##### Gather php 56 information + + ### ################ ################# + + php56 = PHP.objects.get(phpVers="php56") + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-bcmath", + description="A module for PHP applications for using the bcmath library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-common", + description="Common files for PHP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-dba", + description="A database abstraction layer module for PHP applications", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-enchant", + description="Human Language and Character Encoding Support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-gd", + description="A module for PHP applications for using the gd graphics library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-gmp", + description="A module for PHP applications for using the GNU MP library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-imap", + description="A module for PHP applications that use IMAP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-intl", + description="Internationalization extension for PHP application", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-ioncube-loader", + description="Ioncube Loader", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-ldap", + description="A module for PHP applications that use LDAP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-mbstring", + description="A module for PHP applications which need multi-byte string handling", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-mcrypt", + description="Standard PHP module provides mcrypt library support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-mysql", + description="A module for PHP applications that use MySQL databases", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-odbc", + description="A module for PHP applications that use ODBC databases", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-pdo", + description="A database access abstraction module for PHP applications", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php55, + extensionName="lsphp56-pear", + description="PHP Extension and Application Repository framework", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-pgsql", + description="A PostgreSQL database module for PHP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-process", + description="Modules for PHP script using system process interfaces", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-pspell", + description="A module for PHP applications for using pspell interfaces", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-recode", + description="A module for PHP applications for using the recode library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-snmp", + description="A module for PHP applications that query SNMP-managed devices", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-soap", + description="A module for PHP applications that use the SOAP protocol", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-tidy", + description="Standard PHP module provides tidy library support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-xml", + description="A module for PHP applications which use XML", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-xmlrpc", + description="A module for PHP applications which use the XML-RPC protocol", + status=1) + + phpExtension.save() + + ## non-active packages + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-debuginfo", + description="Debug information for package lsphp56", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-mysql56-debuginfo", + description="Debug information for package lsphp56-mysql56", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-devel", + description="Files needed for building PHP extensions", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-mysql56", + description="PHP scripting language for creating dynamic web sites", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-mysqlnd", + description="A module for PHP applications that use MySQL databases", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-opcache", + description="The Zend OPcache", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-sqlite", + description="Extension for the SQLite V2 Embeddable SQL Database Engine", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-xcache", + description="PHP accelerator, optimizer, encoder and dynamic content cacher", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-xcache-admin", + description="XCache Administration", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php56, + extensionName="lsphp56-pecl-imagick", + description="Extension to create and modify images using ImageMagick", + status=0) + + phpExtension.save() + + ### ################ ################# + + ##### Gather php 70 information + + ### ################ ################# + + phpVersion = PHP.objects.get(phpVers="php70") + + phpPath = '' + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php70.xml') + else: + phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp70.xml') + + php = ElementTree.parse(phpPath) + + phpExtensions = php.findall('extension') + + for extension in phpExtensions: + extensionName = extension.find('extensionName').text + extensionDescription = extension.find('extensionDescription').text + status = int(extension.find('status').text) + + phpExtension = installedPackages(phpVers=phpVersion, + extensionName=extensionName, + description=extensionDescription, + status=status) + + phpExtension.save() + + ### ################ ################# + + ##### Gather php 71 information + + ### ################ ################# + + phpVersion = PHP.objects.get(phpVers="php71") + + phpPath = '' + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php71.xml') + else: + phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp71.xml') + + php = ElementTree.parse(phpPath) + + phpExtensions = php.findall('extension') + + for extension in phpExtensions: + extensionName = extension.find('extensionName').text + extensionDescription = extension.find('extensionDescription').text + status = int(extension.find('status').text) + + phpExtension = installedPackages(phpVers=phpVersion, + extensionName=extensionName, + description=extensionDescription, + status=status) + + phpExtension.save() + + if PHP.objects.count() == 6: + + newPHP72 = PHP(phpVers="php72") + newPHP72.save() + + php72Path = '' + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + php72Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php72.xml') + else: + php72Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp72.xml') + + php72 = ElementTree.parse(php72Path) + + php72Extensions = php72.findall('extension') + + for extension in php72Extensions: + extensionName = extension.find('extensionName').text + extensionDescription = extension.find('extensionDescription').text + status = int(extension.find('status').text) + + phpExtension = installedPackages(phpVers=newPHP72, + extensionName=extensionName, + description=extensionDescription, + status=status) + + phpExtension.save() + + if PHP.objects.count() == 7: + + newPHP73 = PHP(phpVers="php73") + newPHP73.save() + + php73Path = '' + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + php73Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php73.xml') + else: + php73Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp73.xml') + + php73 = ElementTree.parse(php73Path) + + php73Extensions = php73.findall('extension') + + for extension in php73Extensions: + extensionName = extension.find('extensionName').text + extensionDescription = extension.find('extensionDescription').text + status = int(extension.find('status').text) + + phpExtension = installedPackages(phpVers=newPHP73, + extensionName=extensionName, + description=extensionDescription, + status=status) + + phpExtension.save() + + if PHP.objects.count() == 8: + + newPHP74 = PHP(phpVers="php74") + newPHP74.save() + + php74Path = '' + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + php74Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php74.xml') + else: + php74Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp74.xml') + + php74 = ElementTree.parse(php74Path) + + php74Extensions = php74.findall('extension') + + for extension in php74Extensions: + extensionName = extension.find('extensionName').text + extensionDescription = extension.find('extensionDescription').text + status = int(extension.find('status').text) + + phpExtension = installedPackages(phpVers=newPHP74, + extensionName=extensionName, + description=extensionDescription, + status=status) + + phpExtension.save() + try: + newPHP80 = PHP(phpVers="php80") + newPHP80.save() + + php80Path = '' + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + php80Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php80.xml') + else: + php80Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp80.xml') + + php80 = ElementTree.parse(php80Path) + + php80Extensions = php80.findall('extension') + + for extension in php80Extensions: + extensionName = extension.find('extensionName').text + extensionDescription = extension.find('extensionDescription').text + status = int(extension.find('status').text) + + phpExtension = installedPackages(phpVers=newPHP80, + extensionName=extensionName, + description=extensionDescription, + status=status) + + phpExtension.save() + except: + pass + + try: + newPHP81 = PHP(phpVers="php81") + newPHP81.save() + + php81Path = '' + + if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8: + php81Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php81.xml') + else: + php81Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp81.xml') + + php81 = ElementTree.parse(php81Path) + + php81Extensions = php81.findall('extension') + + for extension in php81Extensions: + extensionName = extension.find('extensionName').text + extensionDescription = extension.find('extensionDescription').text + status = int(extension.find('status').text) + + phpExtension = installedPackages(phpVers=newPHP81, + extensionName=extensionName, + description=extensionDescription, + status=status) + + phpExtension.save() + except: + pass + + # apache = ApacheController.checkIfApacheInstalled() + apache = 1 + + proc = httpProc(request, 'managePHP/installExtensions.html', + {'phps': PHPManager.findPHPVersions(), 'apache': apache}, 'admin') + return proc.render() + + except KeyError: + return redirect(loadLoginPage) + + +def installExtensionsV2(request): + try: + + if PHP.objects.count() == 0: + for i in range(3, 7): + php = "php" + str(5) + str(i) + newPHP = PHP(phpVers=php) + newPHP.save() + + newPHP = PHP(phpVers="php70") + newPHP.save() + newPHP = PHP(phpVers="php71") + newPHP.save() + + ### Gather php 53 information + + php53 = PHP.objects.get(phpVers="php53") + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-bcmath", + description="A module for PHP applications for using the bcmath library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-common", + description="Common files for PHP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-dba", + description="A database abstraction layer module for PHP applications", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-enchant", + description="Human Language and Character Encoding Support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-gd", + description="A module for PHP applications for using the gd graphics library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-imap", + description="A module for PHP applications that use IMAP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-intl", + description="Internationalization extension for PHP application", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-ioncube-loader", + description="Ioncube Loader", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-ldap", + description="A module for PHP applications that use LDAP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-mbstring", + description="A module for PHP applications which need multi-byte string handling", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-mcrypt", + description="Standard PHP module provides mcrypt library support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-mysql", + description="A module for PHP applications that use MySQL databases", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-odbc", + description="A module for PHP applications that use ODBC databases", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-pdo", + description="A database access abstraction module for PHP applications", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-pear", + description="PHP Extension and Application Repository framework", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-pecl-apc", + description="APC caches and optimizes PHP intermediate code", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-pgsql", + description="A PostgreSQL database module for PHP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-process", + description="Modules for PHP script using system process interfaces", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-pspell", + description="A module for PHP applications for using pspell interfaces", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-recode", + description="A module for PHP applications for using the recode library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-snmp", + description="A module for PHP applications that query SNMP-managed devices", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-soap", + description="A module for PHP applications that use the SOAP protocol", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-tidy", + description="Standard PHP module provides tidy library support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-xml", + description="A module for PHP applications which use XML", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-xmlrpc", + description="A module for PHP applications which use the XML-RPC protocol", + status=1) + + phpExtension.save() + + ## non-active packages + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-debuginfo", + description="Debug information for package lsphp53", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-lsphp53-devel", + description="Files needed for building PHP extensions", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-mysql56", + description="PHP scripting language for creating dynamic web sites", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-mysqlnd", + description="A module for PHP applications that use MySQL databases", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-opcache", + description="The Zend OPcache", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-pecl-apc-devel", + description="APC developer files (header)", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-pecl-apc-panel", + description="APC control panel", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-sqlite", + description="Extension for the SQLite V2 Embeddable SQL Database Engine", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-xcache", + description="PHP accelerator, optimizer, encoder and dynamic content cacher", + status=0) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp53-xcache-admin", + description="XCache Administration", + status=0) + + phpExtension.save() + + ### ################ ################# + + ##### Gather php 54 information + + ### ################ ################# + + php54 = PHP.objects.get(phpVers="php54") + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-bcmath", + description="A module for PHP applications for using the bcmath library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-common", + description="Common files for PHP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp53-dba", + description="A database abstraction layer module for PHP applications", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp54-enchant", + description="Human Language and Character Encoding Support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-gd", + description="A module for PHP applications for using the gd graphics library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-imap", + description="A module for PHP applications that use IMAP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp54-intl", + description="Internationalization extension for PHP application", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-ioncube-loader", + description="Ioncube Loader", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-ldap", + description="A module for PHP applications that use LDAP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-mbstring", + description="A module for PHP applications which need multi-byte string handling", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-mcrypt", + description="Standard PHP module provides mcrypt library support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-mysql", + description="A module for PHP applications that use MySQL databases", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-odbc", + description="A module for PHP applications that use ODBC databases", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-pdo", + description="A database access abstraction module for PHP applications", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-pear", + description="PHP Extension and Application Repository framework", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-pecl-apc", + description="APC caches and optimizes PHP intermediate code", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php53, + extensionName="lsphp54-pgsql", + description="A PostgreSQL database module for PHP", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-process", + description="Modules for PHP script using system process interfaces", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-pspell", + description="A module for PHP applications for using pspell interfaces", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-recode", + description="A module for PHP applications for using the recode library", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-snmp", + description="A module for PHP applications that query SNMP-managed devices", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-soap", + description="A module for PHP applications that use the SOAP protocol", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-tidy", + description="Standard PHP module provides tidy library support", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-xml", + description="A module for PHP applications which use XML", + status=1) + + phpExtension.save() + + phpExtension = installedPackages(phpVers=php54, + extensionName="lsphp54-xmlrpc", + description="A module for PHP applications which use the XML-RPC protocol", + status=1) + + phpExtension.save() + + ## non-active packages phpExtension = installedPackages(phpVers=php54, extensionName="lsphp54-debuginfo", @@ -745,7 +1981,6 @@ def installExtensions(request): ## non-active packages - phpExtension = installedPackages(phpVers=php55, extensionName="lsphp55-debuginfo", description="Debug information for package lsphp55", @@ -992,10 +2227,8 @@ def installExtensions(request): phpExtension.save() - ## non-active packages - phpExtension = installedPackages(phpVers=php56, extensionName="lsphp56-debuginfo", description="Debug information for package lsphp56", @@ -1239,7 +2472,7 @@ def installExtensions(request): phpExtension.save() except: pass - + try: newPHP81 = PHP(phpVers="php81") newPHP81.save() @@ -1271,14 +2504,15 @@ def installExtensions(request): # apache = ApacheController.checkIfApacheInstalled() apache = 1 - - proc = httpProc(request, 'managePHP/installExtensions.html', + + proc = httpProc(request, 'managePHP/installExtensionsV2.html', {'phps': PHPManager.findPHPVersions(), 'apache': apache}, 'admin') return proc.render() except KeyError: return redirect(loadLoginPage) + def getExtensionsInformation(request): try: userID = request.session['userID'] @@ -1318,7 +2552,7 @@ def getExtensionsInformation(request): result = ProcessUtilities.outputExecutioner(command).split('\n') - #records = php.installedpackages_set.all() + # records = php.installedpackages_set.all() json_data = "[" checker = 0 @@ -1362,7 +2596,6 @@ def getExtensionsInformation(request): 'status': status } - if checker == 0: json_data = json_data + json.dumps(dic) checker = 1 @@ -1384,6 +2617,7 @@ def getExtensionsInformation(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def submitExtensionRequest(request): try: userID = request.session['userID'] @@ -1423,6 +2657,7 @@ def submitExtensionRequest(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def getRequestStatus(request): try: userID = request.session['userID'] @@ -1548,6 +2783,7 @@ def getRequestStatus(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def getRequestStatusApache(request): try: userID = request.session['userID'] @@ -1672,9 +2908,10 @@ def getRequestStatusApache(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def editPHPConfigs(request): try: - #apache = ApacheController.checkIfApacheInstalled() + # apache = ApacheController.checkIfApacheInstalled() apache = 1 proc = httpProc(request, 'managePHP/editPHPConfig.html', {'phps': PHPManager.findPHPVersions(), 'apache': apache}, 'admin') @@ -1683,6 +2920,19 @@ def editPHPConfigs(request): except KeyError: return redirect(loadLoginPage) + +def editPHPConfigsV2(request): + try: + # apache = ApacheController.checkIfApacheInstalled() + apache = 1 + proc = httpProc(request, 'managePHP/editPHPConfigV2.html', + {'phps': PHPManager.findPHPVersions(), 'apache': apache}, 'admin') + return proc.render() + + except KeyError: + return redirect(loadLoginPage) + + def getCurrentPHPConfig(request): try: userID = request.session['userID'] @@ -1767,6 +3017,7 @@ def getCurrentPHPConfig(request): except KeyError: return redirect(loadLoginPage) + def savePHPConfigBasic(request): try: userID = request.session['userID'] @@ -1811,7 +3062,7 @@ def savePHPConfigBasic(request): else: allow_url_include = "allow_url_include = Off" - #phpVers = "php" + PHPManager.getPHPString(phpVers) + # phpVers = "php" + PHPManager.getPHPString(phpVers) if request.GET.get('apache', None) == None: apache = 0 @@ -1821,7 +3072,7 @@ def savePHPConfigBasic(request): ## execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py" - execPath = execPath + " savePHPConfigBasic --phpVers '" + phpVers + "' --allow_url_fopen '" + allow_url_fopen +\ + execPath = execPath + " savePHPConfigBasic --phpVers '" + phpVers + "' --allow_url_fopen '" + allow_url_fopen + \ "' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" \ + allow_url_include + "' --memory_limit " + memory_limit + " --max_execution_time " + \ max_execution_time + " --upload_max_filesize " + upload_max_filesize \ @@ -1933,6 +3184,7 @@ def savePHPConfigAdvance(request): logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[saveConfigsToFile]") return HttpResponse("Not Logged in as admin") + ## Restart PHP def restartPHP(request): diff --git a/serverLogs/static/serverLogs/serverLogsV2.js b/serverLogs/static/serverLogs/serverLogsV2.js new file mode 100644 index 000000000..06c5e7cdb --- /dev/null +++ b/serverLogs/static/serverLogs/serverLogsV2.js @@ -0,0 +1,915 @@ +newapp.controller('serverMailV2', function ($scope, $http) { + + $scope.cyberPanelLoading = true; + $scope.installationDetailsForm = true; + + $scope.mailerSettings = function () { + if ($scope.mailer === 'SMTP') { + $scope.installationDetailsForm = false; + } else { + $scope.installationDetailsForm = true; + } + }; + + $scope.saveSMTPSettings = function () { + $scope.cyberPanelLoading = false; + + var url = "/serverlogs/saveSMTPSettings"; + + var data = { + mailer: $scope.mailer, + smtpHost: $scope.smtpHost, + smtpPort: $scope.smtpPort, + smtpUserName: $scope.smtpUserName, + smtpPassword: $scope.smtpPassword + }; + + 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) { + new PNotify({ + title: 'Success', + text: 'Successfully saved.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + }; + +}); +newapp.controller('readAccessLogsV2', function ($scope, $http) { + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "access" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + + $scope.fetchLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "access" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + + $scope.clearLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/clearLogFile"; + + var data = { + fileName: "/usr/local/lsws/logs/access.log" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.cleanStatus === 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + $scope.logsData = ""; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + +}); +newapp.controller('readErrorLogsV2', function ($scope, $http) { + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "error" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus === 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + + $scope.fetchLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "error" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + + $scope.clearLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/clearLogFile"; + + var data = { + fileName: "/usr/local/lsws/logs/error.log" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.cleanStatus === 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + $scope.logsData = ""; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + +}); + +newapp.controller('readEmailLogsV2', function ($scope, $http) { + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "email" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus === 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + + $scope.fetchLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "email" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + + $scope.clearLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/clearLogFile"; + + var data = { + fileName: "/var/log/maillog" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.cleanStatus === 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + $scope.logsData = ""; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + +}); +newapp.controller('readFTPLogsV2', function ($scope, $http) { + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "ftp" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus === 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + + $scope.fetchLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "ftp" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + + $scope.clearLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/clearLogFile"; + + var data = { + fileName: "/var/log/messages" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.cleanStatus === 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + $scope.logsData = ""; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + +}); +newapp.controller('modSecAuditLogsV2', function ($scope, $http) { + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "modSec" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus === 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + + $scope.fetchLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/getLogsFromFile"; + + var data = { + type: "modSec" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + $scope.clearLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverlogs/clearLogFile"; + + var data = { + fileName: "/usr/local/lsws/logs/auditmodsec.log" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.cleanStatus === 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + $scope.logsData = ""; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + }; + +}); \ No newline at end of file diff --git a/serverLogs/templates/serverLogs/accessLogsV2.html b/serverLogs/templates/serverLogs/accessLogsV2.html new file mode 100644 index 000000000..6f5a39772 --- /dev/null +++ b/serverLogs/templates/serverLogs/accessLogsV2.html @@ -0,0 +1,45 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

Access Logs

+

Access Logs for main web server.

+
+
+
+

Last 50 Lines

+ +
+
+
+ +
+
+
+ + +
+
+
+

{% trans "Last 50 Lines Fetched" %}

+
+
+

{% trans "Could not fetch logs. Use the command line to view the log file." %}

+
+
+{% endblock %} diff --git a/serverLogs/templates/serverLogs/emailLogsV2.html b/serverLogs/templates/serverLogs/emailLogsV2.html new file mode 100644 index 000000000..8cc6acf6e --- /dev/null +++ b/serverLogs/templates/serverLogs/emailLogsV2.html @@ -0,0 +1,45 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

Email Logs

+

Email Logs for main web server.

+
+
+
+

Last 50 Lines

+ +
+
+
+ +
+
+
+ + +
+
+
+

{% trans "Last 50 Lines Fetched" %}

+
+
+

{% trans "Could not fetch logs. Use the command line to view the log file." %}

+
+
+{% endblock %} diff --git a/serverLogs/templates/serverLogs/errorLogsV2.html b/serverLogs/templates/serverLogs/errorLogsV2.html new file mode 100644 index 000000000..a7854f595 --- /dev/null +++ b/serverLogs/templates/serverLogs/errorLogsV2.html @@ -0,0 +1,45 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

Error Logs

+

Error Logs for main web server.

+
+
+
+

Last 50 Lines

+ +
+
+
+ +
+
+
+ + +
+
+
+

{% trans "Last 50 Lines Fetched" %}

+
+
+

{% trans "Could not fetch logs. Use the command line to view the log file." %}

+
+
+{% endblock %} diff --git a/serverLogs/templates/serverLogs/ftplogsV2.html b/serverLogs/templates/serverLogs/ftplogsV2.html new file mode 100644 index 000000000..49ad874e2 --- /dev/null +++ b/serverLogs/templates/serverLogs/ftplogsV2.html @@ -0,0 +1,45 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

FTP Logs

+

FTP Logs for main web server.

+
+
+
+

Last 50 Lines

+ +
+
+
+ +
+
+
+ + +
+
+
+

{% trans "Last 50 Lines Fetched" %}

+
+
+

{% trans "Could not fetch logs. Use the command line to view the log file." %}

+
+
+{% endblock %} diff --git a/serverLogs/templates/serverLogs/modSecAuditLogV2.html b/serverLogs/templates/serverLogs/modSecAuditLogV2.html new file mode 100644 index 000000000..b56d26149 --- /dev/null +++ b/serverLogs/templates/serverLogs/modSecAuditLogV2.html @@ -0,0 +1,45 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

ModSecurity Audit Logs

+

ModSecurity Audit Logs

+
+
+
+

Last 50 Lines

+ +
+
+
+ +
+
+
+ + +
+
+
+

{% trans "Last 50 Lines Fetched" %}

+
+
+

{% trans "Could not fetch logs. Use the command line to view the log file." %}

+
+
+{% endblock %} diff --git a/serverLogs/templates/serverLogs/serverMailV2.html b/serverLogs/templates/serverLogs/serverMailV2.html new file mode 100644 index 000000000..dfee9b482 --- /dev/null +++ b/serverLogs/templates/serverLogs/serverMailV2.html @@ -0,0 +1,78 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

Manage Server Mail -

+ {% trans "Mail Docs" %} +
+
+
+

Manage SMTP Hosts

+ +
+
+
+
+

Mailer

+
+
+ +
+
+
+
+

SMTP Host

+
+
+ +
+
+
+
+

Port

+
+
+ +
+
+
+
+

Username

+
+
+ +
+
+
+
+

Password

+
+
+ +
+
+
+
+ +
+
+
+{% endblock %} diff --git a/serverLogs/urls.py b/serverLogs/urls.py index c1bc9748f..8edaa0ca1 100755 --- a/serverLogs/urls.py +++ b/serverLogs/urls.py @@ -3,13 +3,19 @@ from . import views urlpatterns = [ url(r'^$', views.logsHome, name='logsHome'), - url(r'^accessLogs', views.accessLogs, name='accessLogs'), - url(r'^errorLogs', views.errorLogs, name='errorLogs'), + url(r'^V2/accessLogs', views.accessLogs, name='accessLogs'), + url(r'^accessLogsV2', views.accessLogsV2, name='accessLogsV2'), + url(r'^V2/errorLogs', views.errorLogs, name='errorLogs'), + url(r'^errorLogsV2', views.errorLogsV2, name='errorLogsV2'), url(r'^emaillogs', views.emailLogs, name='emaillogs'), + url(r'^V2/emaillogsV2', views.emailLogsV2, name='emaillogsV2'), url(r'^ftplogs', views.ftplogs, name='ftplogs'), + url(r'^V2/ftplogsV2', views.ftplogsV2, name='ftplogsV2'), url(r'^modSecAuditLogs', views.modSecAuditLogs, name='modSecAuditLogs'), - url(r'^getLogsFromFile',views.getLogsFromFile, name="getLogsFromFile"), - url(r'^clearLogFile',views.clearLogFile, name="clearLogFile"), + url(r'^V2/modSecAuditLogsV2', views.modSecAuditLogsV2, name='modSecAuditLogsV2'), + url(r'^getLogsFromFile', views.getLogsFromFile, name="getLogsFromFile"), + url(r'^clearLogFile', views.clearLogFile, name="clearLogFile"), url(r'^serverMail$', views.serverMail, name="serverMail"), + url(r'^serverMailV2$', views.serverMailV2, name="serverMailV2"), url(r'^saveSMTPSettings$', views.saveSMTPSettings, name="saveSMTPSettings"), -] \ No newline at end of file +] diff --git a/serverLogs/views.py b/serverLogs/views.py index 425eb2bfb..ae54d79a2 100755 --- a/serverLogs/views.py +++ b/serverLogs/views.py @@ -9,6 +9,8 @@ from plogical.virtualHostUtilities import virtualHostUtilities from plogical.acl import ACLManager from plogical.processUtilities import ProcessUtilities import os + + # Create your views here. def logsHome(request): @@ -16,31 +18,67 @@ def logsHome(request): None, 'admin') return proc.render() + def accessLogs(request): proc = httpProc(request, 'serverLogs/accessLogs.html', None, 'admin') return proc.render() + +def accessLogsV2(request): + proc = httpProc(request, 'serverLogs/accessLogsV2.html', + None, 'admin') + return proc.render() + + def errorLogs(request): proc = httpProc(request, 'serverLogs/errorLogs.html', None, 'admin') return proc.render() + +def errorLogsV2(request): + proc = httpProc(request, 'serverLogs/errorLogsV2.html', + None, 'admin') + return proc.render() + + def ftplogs(request): proc = httpProc(request, 'serverLogs/ftplogs.html', None, 'admin') return proc.render() + +def ftplogsV2(request): + proc = httpProc(request, 'serverLogs/ftplogsV2.html', + None, 'admin') + return proc.render() + + def emailLogs(request): proc = httpProc(request, 'serverLogs/emailLogs.html', None, 'admin') return proc.render() + +def emailLogsV2(request): + proc = httpProc(request, 'serverLogs/emailLogsV2.html', + None, 'admin') + return proc.render() + + def modSecAuditLogs(request): proc = httpProc(request, 'serverLogs/modSecAuditLog.html', None, 'admin') return proc.render() + +def modSecAuditLogsV2(request): + proc = httpProc(request, 'serverLogs/modSecAuditLogV2.html', + None, 'admin') + return proc.render() + + def getLogsFromFile(request): try: userID = request.session['userID'] @@ -85,11 +123,13 @@ def getLogsFromFile(request): return HttpResponse(final_json) except KeyError as msg: - status = {"status": 0, "logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."} + status = {"status": 0, "logstatus": 0, + "error": "Could not fetch data from log file, please see CyberCP main log file through command line."} logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getLogsFromFile]") final_json = json.dumps(status) return HttpResponse(final_json) + def clearLogFile(request): try: userID = request.session['userID'] @@ -132,6 +172,7 @@ def clearLogFile(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) + def serverMail(request): smtpPath = '/home/cyberpanel/smtpDetails' data = {} @@ -147,6 +188,23 @@ def serverMail(request): data, 'admin') return proc.render() + +def serverMailV2(request): + smtpPath = '/home/cyberpanel/smtpDetails' + data = {} + + if os.path.exists(smtpPath): + mailSettings = json.loads(open(smtpPath, 'r').read()) + data['smtpHost'] = mailSettings['smtpHost'] + data['smtpPort'] = mailSettings['smtpPort'] + data['smtpUserName'] = mailSettings['smtpUserName'] + data['smtpPassword'] = mailSettings['smtpPassword'] + + proc = httpProc(request, 'serverLogs/serverMailV2.html', + data, 'admin') + return proc.render() + + def saveSMTPSettings(request): try: userID = request.session['userID'] @@ -202,7 +260,6 @@ def saveSMTPSettings(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) - status = {"status": 1} final_json = json.dumps(status) return HttpResponse(final_json) diff --git a/serverStatus/static/serverStatus/serverStatusV2.js b/serverStatus/static/serverStatus/serverStatusV2.js new file mode 100644 index 000000000..32a57c500 --- /dev/null +++ b/serverStatus/static/serverStatus/serverStatusV2.js @@ -0,0 +1,650 @@ +newapp.controller('readCyberCPLogFileV2', function ($scope, $http) { + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverstatus/getFurtherDataFromLogFile"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + + $scope.fetchLogs = function () { + + + $scope.logFileLoading = false; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = true; + + + var url = "/serverstatus/getFurtherDataFromLogFile"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.logstatus == 1) { + + $scope.logFileLoading = true; + $scope.logsFeteched = false; + $scope.couldNotFetchLogs = true; + + $scope.logsData = response.data.logsdata; + + + } else { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.logFileLoading = true; + $scope.logsFeteched = true; + $scope.couldNotFetchLogs = false; + + } + + + }; + +}); +newapp.controller('litespeedStatusV2', function ($scope, $http) { + + $scope.restartorStopLoading = true; + $scope.actionResult = true; + $scope.actionResultBad = true; + $scope.serverStatusCouldNotConnect = true; + + + $scope.restartLitespeed = function () { + + + $scope.disableReboot = true; + $scope.disableStop = true; + $scope.restartorStopLoading = false; + + + var url = "/serverstatus/startorstopLitespeed"; + + var data = { + reboot: 1, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.restartorStopLoading = true; + $scope.disableReboot = false; + $scope.disableStop = false; + + if (response.data.reboot == 1) { + + $scope.restartorStopLoading = true; + $scope.actionResult = false; + $scope.actionResultBad = true; + $scope.serverStatusCouldNotConnect = true; + + } else { + + $scope.restartorStopLoading = true; + $scope.actionResult = true; + $scope.actionResultBad = false; + $scope.serverStatusCouldNotConnect = true; + } + + + } + + function cantLoadInitialDatas(response) { + $scope.restartorStopLoading = true; + $scope.actionResult = true; + $scope.actionResultBad = true; + $scope.serverStatusCouldNotConnect = false; + $scope.disableReboot = false; + $scope.disableStop = false; + } + + + }; + + $scope.stopLitespeed = function () { + + + $scope.disableReboot = true; + $scope.disableStop = true; + $scope.restartorStopLoading = false; + + + var url = "/serverstatus/startorstopLitespeed"; + + var data = { + reboot: 0, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + $scope.restartorStopLoading = true; + $scope.disableReboot = false; + $scope.disableStop = false; + + if (response.data.shutdown == 1) { + + $scope.restartorStopLoading = true; + $scope.actionResult = false; + $scope.actionResultBad = true; + $scope.serverStatusCouldNotConnect = true; + + } else { + + $scope.restartorStopLoading = true; + $scope.actionResult = true; + $scope.actionResultBad = false; + $scope.serverStatusCouldNotConnect = true; + } + + + } + + function cantLoadInitialDatas(response) { + $scope.restartorStopLoading = true; + $scope.actionResult = true; + $scope.actionResultBad = true; + $scope.serverStatusCouldNotConnect = false; + $scope.disableReboot = false; + $scope.disableStop = false; + } + + + }; + + /// License Manager + + $scope.cpLoading = true; + $scope.fetchedData = true; + $scope.changeSerialBox = true; + + $scope.hideLicenseStatus = function () { + $scope.fetchedData = true; + }; + + $scope.licenseStatus = function () { + + $scope.cpLoading = false; + $scope.changeSerialBox = true; + + var url = "/serverstatus/licenseStatus"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.cpLoading = true; + $scope.fetchedData = false; + new PNotify({ + title: 'Success!', + text: 'Status successfully fetched', + type: 'success' + }); + $scope.lsSerial = response.data.lsSerial; + $scope.lsexpiration = response.data.lsexpiration; + } else { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: response.data.erroMessage, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + } + + + }; + $scope.showSerialBox = function () { + $scope.fetchedData = true; + $scope.changeSerialBox = false; + }; + $scope.changeLicense = function () { + + $scope.cpLoading = false; + + var url = "/serverstatus/changeLicense"; + + var data = {newKey: $scope.newKey}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.cpLoading = true; + new PNotify({ + title: 'Success!', + text: 'License successfully Updated', + type: 'success' + }); + } else { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: response.data.erroMessage, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + } + + + }; + + $scope.refreshLicense = function () { + + $scope.cpLoading = false; + + var url = "/serverstatus/refreshLicense"; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + data = {}; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.cpLoading = true; + new PNotify({ + title: 'Success!', + text: 'License successfully refreshed', + type: 'success' + }); + } else { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: response.data.erroMessage, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + } + + + }; + +}); + +newapp.controller('lswsSwitchV2', function ($scope, $http, $timeout, $window) { + + + $scope.cyberPanelLoading = true; + $scope.installBoxGen = true; + + $scope.confrimtril = function () { + $('#confrimtril').show(); + } + + $scope.switchTOLSWS = function () { + + $scope.cyberPanelLoading = false; + $scope.installBoxGen = true; + + url = "/serverstatus/switchTOLSWS"; + + var data = { + licenseKey: $scope.licenseKey + }; + + 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) { + $scope.installBoxGen = false; + getRequestStatus(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + function getRequestStatus() { + $scope.cyberPanelLoading = false; + + url = "/serverstatus/switchTOLSWSStatus"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + if (response.data.abort === 0) { + $scope.requestData = response.data.requestStatus; + $timeout(getRequestStatus, 1000); + } else { + // Notifications + $scope.cyberPanelLoading = true; + $timeout.cancel(); + $scope.requestData = response.data.requestStatus; + if (response.data.installed === 1) { + $timeout(function () { + $window.location.reload(); + }, 3000); + } + + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + + } + + } + +}); +newapp.controller('topProcessesV2', function ($scope, $http, $timeout) { + + $scope.cyberPanelLoading = true; + + $scope.topProcessesStatus = function () { + + $scope.cyberPanelLoading = false; + + url = "/serverstatus/topProcessesStatus"; + + var data = {}; + + 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) { + $scope.processes = JSON.parse(response.data.data); + + //CPU Details + $scope.cores = response.data.cores; + $scope.modelName = response.data.modelName; + $scope.cpuMHZ = response.data.cpuMHZ; + $scope.cacheSize = response.data.cacheSize; + + //CPU Load + $scope.cpuNow = response.data.cpuNow; + $scope.cpuOne = response.data.cpuOne; + $scope.cpuFive = response.data.cpuFive; + $scope.cpuFifteen = response.data.cpuFifteen; + + //CPU Time spent + $scope.ioWait = response.data.ioWait; + $scope.idleTime = response.data.idleTime; + $scope.hwInterrupts = response.data.hwInterrupts; + $scope.Softirqs = response.data.Softirqs; + + //Memory + $scope.totalMemory = response.data.totalMemory; + $scope.freeMemory = response.data.freeMemory; + $scope.usedMemory = response.data.usedMemory; + $scope.buffCache = response.data.buffCache; + + //Swap + $scope.swapTotalMemory = response.data.swapTotalMemory; + $scope.swapFreeMemory = response.data.swapFreeMemory; + $scope.swapUsedMemory = response.data.swapUsedMemory; + $scope.swapBuffCache = response.data.swapBuffCache; + + //Processes + $scope.totalProcesses = response.data.totalProcesses; + $scope.runningProcesses = response.data.runningProcesses; + $scope.sleepingProcesses = response.data.sleepingProcesses; + $scope.stoppedProcesses = response.data.stoppedProcesses; + $scope.zombieProcesses = response.data.zombieProcesses; + + $timeout($scope.topProcessesStatus, 3000); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + $scope.topProcessesStatus(); + + $scope.killProcess = function (pid) { + + $scope.cyberPanelLoading = false; + + url = "/serverstatus/killProcess"; + + var data = { + pid: pid + }; + + 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) { + new PNotify({ + title: 'Success', + text: 'Process successfully killed.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(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/serverStatus/templates/serverStatus/cybercpmainlogfile.html b/serverStatus/templates/serverStatus/cybercpmainlogfile.html index 4a7e95828..d240f3fdf 100755 --- a/serverStatus/templates/serverStatus/cybercpmainlogfile.html +++ b/serverStatus/templates/serverStatus/cybercpmainlogfile.html @@ -4,21 +4,22 @@ {% block content %} -{% load static %} -{% get_current_language as LANGUAGE_CODE %} - + {% load static %} + {% get_current_language as LANGUAGE_CODE %} + -
-
-

{% trans "CyberPanel Main Log File" %}

-

{% trans "This log file corresponds to errors generated by CyberPanel for your domain errors log you can look into /home/domain/logs." %}

-
+
+
+

{% trans "CyberPanel Main Log File" %}

+

{% trans "This log file corresponds to errors generated by CyberPanel for your domain errors log you can look into /home/domain/logs." %}

+
-
-
+
+

- {% trans "Last 50 Lines" %} + {% trans "Last 50 Lines" %}

@@ -30,40 +31,36 @@
-
- +
-

{% trans "Last 50 Lines Fetched" %}

-
+

{% trans "Last 50 Lines Fetched" %}

+
-
-

{% trans "Could not fetch logs. Use the command line to view the log file." %}

-
- +
+

{% trans "Could not fetch logs. Use the command line to view the log file." %}

+
- - -
-
+
-
+
{% endblock %} diff --git a/serverStatus/templates/serverStatus/cybercpmainlogfileV2.html b/serverStatus/templates/serverStatus/cybercpmainlogfileV2.html new file mode 100644 index 000000000..4d62799b6 --- /dev/null +++ b/serverStatus/templates/serverStatus/cybercpmainlogfileV2.html @@ -0,0 +1,42 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

CyberPanel Main Log File

+

This log file corresponds to errors generated by + CyberPanel for your domain errors log you can look into /home/domain/logs.

+
+
+
+

Last 50 Lines

+ +
+
+
+ +
+
+
+ +
+
+
+

{% trans "Last 50 Lines Fetched" %}

+
+
+

{% trans "Could not fetch logs. Use the command line to view the log file." %}

+
+
+{% endblock %} diff --git a/serverStatus/templates/serverStatus/litespeedStatusV2.html b/serverStatus/templates/serverStatus/litespeedStatusV2.html new file mode 100644 index 000000000..5502948d8 --- /dev/null +++ b/serverStatus/templates/serverStatus/litespeedStatusV2.html @@ -0,0 +1,356 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + {% if OLS %} +
+
+
+

LiteSpeed Status:

+ +
+

On this page you can get information regarding your + LiteSpeed processes.

+
+ {% if processList %} +
+
+

LiteSpeed Processes

+
+
+
+ + + + + + + + + + {% for items in processList %} + + + + {% if forloop.counter == 1 %} + + {% elif forloop.counter == 2 %} + + {% else %} + + {% endif %} + {% endfor %} + + +
+ # + + Process ID + + Name +
+ {{ forloop.counter }} + + {{ items }} + + Main Process + + lscgid Process + + Worker Process +
+
+
+
+ + + +
+ + + +
+

{% trans "Action successful." %}

+
+
+

{% trans "Error Occurred. See CyberPanel main log file." %}

+
+
+

{% trans "Could not connect to server." %}

+
+ {% endif %} +
+
+
+
+

Switch to LiteSpeed Enterprise Web Server

+ +
+
+
+
+
+

LiteSpeed Serial No. (License Key)

+
+
+ +
+
+
+
+
+ + +
+ + +
+

{% trans "Note: If you select 15 days trial there is no need to enter the serial key, CyberPanel will auto fetch 15 days trial key for you. Make sure this server have not used trial already." %}

+
+
+

{% trans "WARNING: You cannot revert back to OpenLiteSpeed if you choose not to purchase a LiteSpeed Enterprise license after the 15 day trial period. We recommend you test the Enterprise trial on a separate server." %}

+
+
+
+
+
+ +

With great wisdom comes great responsibility.

+ +
+
+ +
+
+
+
+
+ {% else %} +
+
+
+

LiteSpeed Status:

+ +
+

On this page you can get information regarding your + LiteSpeed processes.

+
+
+ {% if message != 0 %} + {% if message == 2 %} +
+
+

Warning

+

It looks like your license does not include CyberPanel bundle. Click here to see the + packages and upgrade to CyberPanel bundle.

+
+
+ {% else %} +
+
+

Warning

+

It looks like your license has expired. Kindly renew your license.

+
+
+ {% endif %} + {% endif %} +
+ {% if processList %} + +
+
+
+
+
+ + +

+ {% trans "LiteSpeed Processes" %} +

+ + + + + + + + + + + {% for items in processList %} + + + + + + {% if forloop.counter == 1 %} + + + {% elif forloop.counter == 2 %} + + + {% else %} + + + {% endif %} + + {% endfor %} + + +
#{% trans "Process ID" %}{% trans "Name" %}
{{ forloop.counter }} {{ items }}{% trans "Main Process" %}{% trans "lscgid Process" %}{% trans "Worker Process" %}
+ + + + + + + + + +
+

{% trans "Action successful." %}

+
+ + +
+

{% trans "Error Occurred. See CyberPanel main log file." %}

+
+ + +
+

{% trans "Could not connect to server." %}

+
+ +
+
+
+
+
+ + {% endif %} +
+
+

+ {% trans "License Manager" %} +

+ +
+
+ + + + + + + +
+ +
+
+
+ +
+
+

{$ lsSerial $}

+

{$ lsexpiration $}

+
+
+
+ +
+ + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ + + + +
+
+
+
+ +
+
+ {% endif %} +{% endblock %} diff --git a/serverStatus/templates/serverStatus/topProcessesV2.html b/serverStatus/templates/serverStatus/topProcessesV2.html new file mode 100644 index 000000000..d5b89ba3d --- /dev/null +++ b/serverStatus/templates/serverStatus/topProcessesV2.html @@ -0,0 +1,336 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+
+

Top Processes

+ +
+

List of top processes on your server. (Refresh every + 3 seconds)

+
+
+
+
+
+ + + + + + + + + + + + + + + + + +
+ Cores + + Model Name + + CPU Mhz + + Cache Size +
+ {$ cores $} + + {$ modelName $} + + {$ cpuMHZ $} + + {$ cacheSize $} +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+ Processes + + Running + + Sleeping + + Stopped + + Zombie +
+ {$ totalProcesses $} + + {$ runningProcesses $} + + {$ sleepingProcesses $} + + {$ stoppedProcesses $} + + {$ zombieProcesses $} +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + +
+ CPU Load + + 1 Min + + 5 Min + + 15 Min +
+ {$ cpuNow $} + + {$ cpuOne $} + + {$ cpuFive $} + + {$ cpuFifteen $} +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
+ I/O Wait + + Idle Time + + HW Interrupts + + Softirqs +
+ {$ ioWait $} + + {$ idleTime $} + + {$ hwInterrupts $} + + {$ Softirqs $} +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + +
+ Memory + + Free + + Used + + buff/cache +
+ {$ totalMemory $} + + {$ freeMemory $} + + {$ usedMemory $} + + {$ buffCache $} +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
+ SWAP + + Free + + Used + + buff/cache +
+ {$ swapTotalMemory $} + + {$ swapFreeMemory $} + + {$ swapUsedMemory $} + + {$ swapBuffCache $} +
+
+
+
+
+

Top Processes

+
+
+
+ + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ PID + + User + + VIRT + + RES + + State + + %CPU + + %MEM + + Time + + Command + + Actions +
+ +
+
+
+
+{% endblock %} diff --git a/serverStatus/urls.py b/serverStatus/urls.py index ca33c74b0..b2f80bf78 100755 --- a/serverStatus/urls.py +++ b/serverStatus/urls.py @@ -4,9 +4,11 @@ from . import views urlpatterns = [ url(r'^$', views.serverStatusHome, name='serverStatusHome'), url(r'^litespeedStatus$', views.litespeedStatus, name='litespeedStatus'), + url(r'^V2/litespeedStatusV2$', views.litespeedStatusV2, name='litespeedStatusV2'), url(r'^startorstopLitespeed$', views.stopOrRestartLitespeed, name='startorstopLitespeed'), url(r'^cyberCPMainLogFile$', views.cyberCPMainLogFile, name='cyberCPMainLogFile'), - url(r'^getFurtherDataFromLogFile$',views.getFurtherDataFromLogFile,name='getFurtherDataFromLogFile'), + url(r'^V2/cyberCPMainLogFileV2$', views.cyberCPMainLogFileV2, name='cyberCPMainLogFileV2'), + url(r'^getFurtherDataFromLogFile$', views.getFurtherDataFromLogFile, name='getFurtherDataFromLogFile'), url(r'^servicesStatus$', views.servicesStatus, name='servicesStatus'), url(r'^servicesAction$', views.servicesAction, name='servicesAction'), @@ -17,6 +19,7 @@ urlpatterns = [ url(r'^changeLicense$', views.changeLicense, name='changeLicense'), url(r'^refreshLicense$', views.refreshLicense, name='refreshLicense'), url(r'^topProcesses$', views.topProcesses, name='topProcesses'), + url(r'^V2/topProcessesV2$', views.topProcessesV2, name='topProcessesV2'), url(r'^topProcessesStatus$', views.topProcessesStatus, name='topProcessesStatus'), url(r'^killProcess$', views.killProcess, name='killProcess'), url(r'^packageManager$', views.packageManager, name='packageManager'), @@ -27,4 +30,4 @@ urlpatterns = [ url(r'^CyberPanelPort$', views.CyberPanelPort, name='CyberPanelPort'), url(r'^submitPortChange$', views.submitPortChange, name='submitPortChange'), -] \ No newline at end of file +] diff --git a/serverStatus/views.py b/serverStatus/views.py index 43a453566..96fbfebc0 100755 --- a/serverStatus/views.py +++ b/serverStatus/views.py @@ -28,11 +28,13 @@ EXPIRE = 3 VERSION = '2.3' BUILD = 4 + def serverStatusHome(request): proc = httpProc(request, 'serverStatus/index.html', None, 'admin') return proc.render() + def litespeedStatus(request): try: userID = request.session['userID'] @@ -91,6 +93,66 @@ def litespeedStatus(request): logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") return redirect(loadLoginPage) + +def litespeedStatusV2(request): + try: + userID = request.session['userID'] + + processList = ProcessUtilities.getLitespeedProcessNumber() + + OLS = 0 + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + OLS = 1 + + message = 0 + + if request.META['QUERY_STRING'] == 'bundle': + message = '' + message = BUNDLE + elif request.META['QUERY_STRING'] == 'expire': + message = 'It looks like your license has expired. Kindly renew your license.' + message = EXPIRE + else: + message = NOTHING + try: + + versionInformation = ProcessUtilities.outputExecutioner(["/usr/local/lsws/bin/lshttpd", "-v"]).split("\n") + lsversion = versionInformation[0] + modules = versionInformation[1] + + counter = 0 + loadedModules = [] + + for items in versionInformation: + if counter == 0 or counter == 1: + counter = counter + 1 + continue + else: + loadedModules.append(items) + + except BaseException as msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") + proc = httpProc(request, 'serverStatus/litespeedStatus.html', + {"processList": processList, + "liteSpeedVersionStatus": "For some reaons not able to load version details, see CyberCP main log file.", + 'OLS': OLS, 'message': message}, 'admin') + return proc.render() + if (processList != 0): + dataForHtml = {"processList": processList, "lsversion": lsversion, "modules": modules, + "loadedModules": loadedModules, 'OLS': OLS, 'message': message} + proc = httpProc(request, 'serverStatus/litespeedStatusV2.html', dataForHtml, 'admin') + return proc.render() + else: + dataForHtml = {"lsversion": lsversion, "modules": modules, + "loadedModules": loadedModules, 'OLS': OLS, 'message': message} + proc = httpProc(request, 'serverStatus/litespeedStatusV2.html', dataForHtml, 'admin') + return proc.render() + + except KeyError as msg: + logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]") + return redirect(loadLoginPage) + + def stopOrRestartLitespeed(request): try: userID = request.session['userID'] @@ -124,10 +186,17 @@ def stopOrRestartLitespeed(request): logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]") return HttpResponse("Not Logged in as admin") + def cyberCPMainLogFile(request): proc = httpProc(request, 'serverStatus/cybercpmainlogfile.html', None, 'admin') return proc.render() + +def cyberCPMainLogFileV2(request): + proc = httpProc(request, 'serverStatus/cybercpmainlogfileV2.html', None, 'admin') + return proc.render() + + def getFurtherDataFromLogFile(request): try: userID = request.session['userID'] @@ -151,6 +220,7 @@ def getFurtherDataFromLogFile(request): logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]") return HttpResponse("Not Logged in as admin") + def services(request): data = {} @@ -168,6 +238,7 @@ def services(request): proc = httpProc(request, 'serverStatus/services.html', data, 'admin') return proc.render() + def servicesStatus(request): try: userID = request.session['userID'] @@ -276,6 +347,7 @@ def servicesStatus(request): except KeyError: return redirect(loadLoginPage) + def servicesAction(request): try: userID = request.session['userID'] @@ -328,6 +400,7 @@ def servicesAction(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def switchTOLSWS(request): try: userID = request.session['userID'] @@ -361,6 +434,7 @@ def switchTOLSWS(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) + def switchTOLSWSStatus(request): try: @@ -387,10 +461,11 @@ def switchTOLSWSStatus(request): except BaseException as msg: command = "sudo rm -f " + serverStatusUtil.ServerStatusUtil.lswsInstallStatusPath ProcessUtilities.popenExecutioner(command) - data_ret = {'status': 0,'abort': 1, 'requestStatus': str(msg), 'installed': 0} + data_ret = {'status': 0, 'abort': 1, 'requestStatus': str(msg), 'installed': 0} json_data = json.dumps(data_ret) return HttpResponse(json_data) + def licenseStatus(request): try: userID = request.session['userID'] @@ -407,7 +482,8 @@ def licenseStatus(request): serial = ProcessUtilities.outputExecutioner(command) if serial.find('No such file or directory') > -1: - final_dic = {'status': 1, "erroMessage": 0, 'lsSerial': 'Trial License in use.', 'lsexpiration': 'Trial license expires 15 days after activation.'} + final_dic = {'status': 1, "erroMessage": 0, 'lsSerial': 'Trial License in use.', + 'lsexpiration': 'Trial license expires 15 days after activation.'} final_json = json.dumps(final_dic) return HttpResponse(final_json) @@ -427,6 +503,7 @@ def licenseStatus(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def refreshLicense(request): try: userID = request.session['userID'] @@ -439,7 +516,6 @@ def refreshLicense(request): else: return ACLManager.loadErrorJson('status', 0) - command = 'sudo /usr/local/lsws/bin/lshttpd -V' ProcessUtilities.outputExecutioner(command) @@ -512,6 +588,12 @@ def topProcesses(request): proc = httpProc(request, "serverStatus/topProcesses.html", None, 'admin') return proc.render() + +def topProcessesV2(request): + proc = httpProc(request, "serverStatus/topProcessesV2.html", None, 'admin') + return proc.render() + + def topProcessesStatus(request): try: userID = request.session['userID'] @@ -586,7 +668,6 @@ def topProcessesStatus(request): memoryInf0[1] = list(filter(None, memoryInf0[1].split(' '))) memoryInf0[2] = list(filter(None, memoryInf0[2].split(' '))) - try: data['totalMemory'] = '%sMB' % (memoryInf0[1][1]) except: @@ -606,7 +687,6 @@ def topProcessesStatus(request): except: data['buffCache'] = '%sMB' % ('0') - ## Swap try: @@ -681,8 +761,8 @@ def topProcessesStatus(request): total, used, free = shutil.disk_usage("/") data['TotalDisk'] = '%s GB' % (total // (2 ** 30)) - data['TotalDiskUsed'] = '%s GB' % (used // (2 ** 30)) - data['TotalDiskFree'] =' %s GB' % (free // (2 ** 30)) + data['TotalDiskUsed'] = '%s GB' % (used // (2 ** 30)) + data['TotalDiskFree'] = ' %s GB' % (free // (2 ** 30)) final_json = json.dumps(data) return HttpResponse(final_json) @@ -692,6 +772,7 @@ def topProcessesStatus(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) + def killProcess(request): try: userID = request.session['userID'] @@ -721,10 +802,12 @@ def killProcess(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def packageManager(request): proc = httpProc(request, "serverStatus/packageManager.html", None, 'admin') return proc.render() + def fetchPackages(request): try: @@ -842,8 +925,7 @@ def fetchPackages(request): ## make list of packages that need update - - #if os.path.exists(ProcessUtilities.debugPath): + # if os.path.exists(ProcessUtilities.debugPath): # logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages))) from s3Backups.s3Backups import S3Backups @@ -857,7 +939,7 @@ def fetchPackages(request): counter = 0 if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages))) + logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages))) import re for items in finalPackages: @@ -896,7 +978,9 @@ def fetchPackages(request): else: lock = 0 - dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade, 'lock': lock} + dic = {'package': nowSplitted[0].split('/')[0], + 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), + 'upgrade': upgrade, 'lock': lock} counter = counter + 1 if checker == 0: @@ -923,7 +1007,6 @@ def fetchPackages(request): else: upgrade = 'Upgrade available' - if details[0].split('.')[0] in locked: lock = 1 else: @@ -965,7 +1048,8 @@ def fetchPackages(request): json_data = json_data + ']' - data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination, 'fetchedPackages': counter, 'totalPackages': len(packages)} + data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination, 'fetchedPackages': counter, + 'totalPackages': len(packages)} json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -974,6 +1058,7 @@ def fetchPackages(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) + def fetchPackageDetails(request): try: @@ -1004,6 +1089,7 @@ def fetchPackageDetails(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) + def updatePackage(request): try: @@ -1027,7 +1113,7 @@ def updatePackage(request): extraArgs = {} extraArgs['package'] = package - from plogical.applicationInstaller import ApplicationInstaller + from plogical.applicationInstaller import ApplicationInstaller background = ApplicationInstaller('updatePackage', extraArgs) background.start() @@ -1043,6 +1129,7 @@ def updatePackage(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) + def lockStatus(request): try: @@ -1179,11 +1266,11 @@ def submitPortChange(request): ProcessUtilities.executioner('systemctl restart lscpd') - data_ret = {'status': 1,} + data_ret = {'status': 1, } json_data = json.dumps(data_ret) return HttpResponse(json_data) except BaseException as msg: data_ret = {'status': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) - return HttpResponse(json_data) \ No newline at end of file + return HttpResponse(json_data) diff --git a/tuning/static/tuning/tuningV2.js b/tuning/static/tuning/tuningV2.js new file mode 100644 index 000000000..57e7bb334 --- /dev/null +++ b/tuning/static/tuning/tuningV2.js @@ -0,0 +1,350 @@ +$("#tuningLoading").hide(); +$("#canNotFetchTuning").hide(); +$("#notTuned").hide(); +$("#tuned").hide(); +$("#phpDetails").hide(); +$("#tunePHPLoading").hide(); + + +newapp.controller('litespeedTuningV2', function ($scope, $http) { + + + url = "/tuning/tuneLitespeed"; + + var data = { + status: "fetch" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetch_status == 1) { + + $("#canNotFetchTuning").hide(); + + var currentTuningData = JSON.parse(response.data.tuning_data); + + $scope.maxConnections = currentTuningData.maxConnections; + $scope.maxSSLConnections = currentTuningData.maxSSLConnections; + $scope.connectionTimeOut = currentTuningData.connTimeout; + $scope.keepAliveTimeOut = currentTuningData.keepAliveTimeout; + $scope.cacheSizeInMemory = currentTuningData.totalInMemCacheSize; + + if (currentTuningData.enableGzipCompress == 1) + $scope.gzipStatus = "Enable" + else + $scope.gzipStatus = "Disabled" + + + } + + + } + + function cantLoadInitialDatas(response) { + $errMessage = response.data.error_message; + $("#canNotFetchTuning").fadeIn(); + } + + + $scope.saveTuningSettings = function () { + + $("#tuningLoading").fadeIn(); + $('#tuned').hide(); + + var maxConn = $scope.maxConnections; + var maxSSLConn = $scope.maxSSLConnections; + var connTime = $scope.connectionTimeOut; + var keepAlive = $scope.keepAliveTimeOut; + var inMemCache = $scope.cacheSizeInMemory; + var gzipCompression = $scope.gzipCompression; + + url = "/tuning/tuneLitespeed"; + + + var data = { + maxConn: maxConn, + maxSSLConn: maxSSLConn, + keepAlive: keepAlive, + connTime: connTime, + inMemCache: inMemCache, + gzipCompression: gzipCompression, + status: "save" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.tuneStatus == 1) { + + $("#canNotFetchTuning").hide(); + $("#tuned").fadeIn(); + $("#notTuned").hide(); + $("#tuningLoading").hide(); + } else { + $scope.errMessage = response.data.error_message; + $("#notTuned").fadeIn(); + $("#tuned").hide(); + $("#tuningLoading").hide(); + } + + } + + + function cantLoadInitialDatas(response) { + $scope.errMessage = response.data.error_message; + $("#notTuned").fadeIn(); + $("#tuned").hide(); + $("#tuningLoading").hide(); + } + + + }; + + +}); +/* Java script code for litespeed tuning ends here */ +$('#canNotFetch').hide(); +$('#successfullyFetched').hide(); +$('#successfullyTuned').hide(); +$('#canNotTune').hide(); + +newapp.controller('tunePHPV2', function ($scope, $http) { + + $scope.hideDetails = true; + + + $scope.fetchPHPDetails = function () { + + $("#tunePHPLoading").fadeIn(); + + + url = "/tuning/tunePHP"; + + + var data = { + status: "fetch", + domainSelection: $scope.domainSelection, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetch_status == 1) { + + $("#tunePHPLoading").hide(); + $('#canNotFetch').hide(); + $('#successfullyTuned').hide(); + $('#canNotTune').hide(); + + + $('#successfullyFetched').fadeIn(); + + var phpData = JSON.parse(response.data.tuning_data); + + $scope.initTimeout = Number(phpData.initTimeout); + $scope.maxConns = Number(phpData.maxConns); + $scope.memSoftLimit = phpData.memSoftLimit; + $scope.memHardLimit = phpData.memHardLimit; + $scope.procSoftLimit = Number(phpData.procSoftLimit); + $scope.procHardLimit = Number(phpData.procHardLimit); + + + if (phpData.persistConn == "1") + $scope.persistStatus = "Enabled"; + else + $scope.persistStatus = "Disabled"; + + $scope.hideDetails = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + $errMessage = response.data.error_message; + $('#canNotFetch').fadeIn(); + $('#successfullyFetched').hide(); + $('#successfullyTuned').hide(); + $('#canNotTune').hide(); + } + }; + + + $scope.fetchPHPDetails = function () { + + + $("#tunePHPLoading").fadeIn(); + + + url = "/tuning/tunePHP"; + + + var data = { + status: "fetch", + domainSelection: $scope.domainSelection, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetch_status == 1) { + + $("#tunePHPLoading").hide(); + + $('#canNotFetch').hide(); + $('#successfullyTuned').hide(); + $('#canNotTune').hide(); + + + $('#successfullyFetched').fadeIn(); + + var phpData = JSON.parse(response.data.tuning_data); + + $scope.initTimeout = Number(phpData.initTimeout); + $scope.maxConns = Number(phpData.maxConns); + $scope.memSoftLimit = phpData.memSoftLimit; + $scope.memHardLimit = phpData.memHardLimit; + $scope.procSoftLimit = Number(phpData.procSoftLimit); + $scope.procHardLimit = Number(phpData.procHardLimit); + + + if (phpData.persistConn == "1") + $scope.persistStatus = "Enabled"; + else + $scope.persistStatus = "Disabled"; + + $scope.hideDetails = false; + + + } + + + } + + function cantLoadInitialDatas(response) { + $errMessage = response.data.error_message; + $('#canNotFetch').fadeIn(); + $('#successfullyFetched').hide(); + $('#successfullyTuned').hide(); + $('#canNotTune').hide(); + } + }; + + + $scope.tunePHPFunc = function () { + + + $("#tunePHPLoading").fadeIn(); + + + var initTimeout = $scope.initTimeout; + var maxConns = $scope.maxConns; + var memSoftLimit = $scope.memSoftLimit; + var memHardLimit = $scope.memHardLimit; + var procSoftLimit = $scope.procSoftLimit; + var procHardLimit = $scope.procHardLimit; + var persistConn = $scope.persistConn; + + + url = "/tuning/tunePHP"; + + + var data = { + status: "save", + domainSelection: $scope.domainSelection, + initTimeout: initTimeout, + maxConns: maxConns, + memSoftLimit: memSoftLimit, + memHardLimit: memHardLimit, + procSoftLimit: procSoftLimit, + procHardLimit: procHardLimit, + persistConn: persistConn + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.tuneStatus == 1) { + + $scope.phpVersionTuned = $scope.domainSelection; + + $("#tunePHPLoading").hide(); + $('#canNotFetch').hide(); + $('#successfullyFetched').hide(); + $('#canNotTune').hide(); + $('#successfullyTuned').fadeIn(); + $scope.hideDetails = false; + } else { + $("#tunePHPLoading").hide(); + $('#canNotFetch').hide(); + $('#successfullyFetched').hide(); + $('#canNotTune').fadeIn(); + $('#successfullyTuned').hide(); + $scope.errorMessage = response.data.error_message; + $scope.hideDetails = false; + } + + + } + + function cantLoadInitialDatas(response) { + $errMessage = response.data.error_message; + $("#tunePHPLoading").hide(); + $('#canNotFetch').hide(); + $('#successfullyFetched').hide(); + $('#canNotTune').fadeIn(); + $('#successfullyTuned').hide(); + } + }; + + +}); \ No newline at end of file diff --git a/tuning/templates/tuning/liteSpeedTuningV2.html b/tuning/templates/tuning/liteSpeedTuningV2.html new file mode 100644 index 000000000..550cf1146 --- /dev/null +++ b/tuning/templates/tuning/liteSpeedTuningV2.html @@ -0,0 +1,105 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+

LiteSpeed Tuning

+

You can use this page to tweak your server according to + your website requirments.

+
+
+
+

Tuning Details

+ +
+
+
+
+
+

Max Connections

+
+
+ +
+
+
+
+

Max SSL Connections

+
+
+ +
+
+
+
+

Connection Timeout

+
+
+ +
+
+
+
+

Keep Alive Timeout

+
+
+ +
+
+
+
+

Cache Size in memory

+
+
+ +
+
+
+
+

Enable GZIP Compression

+
+
+ +
+
+ {$ gzipStatus $} +
+
+
+ +
+ +
+
+

{% trans "Cannot fetch Current Value, but you can still submit new changes, error reported from server:" %} + {$ errMessage $}

+
+
+

{% trans "Cannot save details, Error Message: " %}{$ errMessage $}

+
+
+

{% trans "Web Server Successfully tuned." %}

+
+
+ +
+
+
+{% endblock %} diff --git a/tuning/templates/tuning/phpTuningV2.html b/tuning/templates/tuning/phpTuningV2.html new file mode 100644 index 000000000..a37a890c6 --- /dev/null +++ b/tuning/templates/tuning/phpTuningV2.html @@ -0,0 +1,266 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + {% if OLS %} +
+
+

PHP Tuning

+

Set how each version of PHP behaves in your server + here.

+
+
+
+

Select PHP Version

+ +
+
+
+
+
+
+

Select Domain

+
+
+ +
+
+
+
+

Initial Request Timeout (secs)

+
+
+ +
+
+
+
+

Max Connections

+
+
+ +
+
+
+
+

Memory Soft Limit

+
+
+ +
+
+
+
+

Memory Hard Limit

+
+
+ +
+
+
+
+

Process Soft Limit

+
+
+ +
+
+
+
+

Process Hard Limit

+
+
+ +
+
+
+
+

Persistent Connection

+
+
+ +
+
+ {$ persistStatus $} +
+
+
+ +
+
+
+

{% trans "Cannot fetch details. Error message:" %} {$ errorMessage $}

+
+
+

{% trans "Cannot tune. Error message:" %} {$ errorMessage $}

+
+
+

{% trans "Details Successfully fetched." %}

+
+
+

{% trans "PHP for " %}{$ phpVersionTuned + $} {% trans "Successfully tuned." %}

+
+
+
+
+
+
+ {% else %} +
+
+

PHP Tuning

+

Set how each version of PHP behaves in your server + here.

+
+
+
+

Select PHP Version

+ +
+
+
+
+
+
+

Select PHP

+
+
+ +
+
+
+
+

Initial Request Timeout (secs)

+
+
+ +
+
+
+
+

Max Connections

+
+
+ +
+
+
+
+

Memory Soft Limit

+
+
+ +
+
+
+
+

Memory Hard Limit

+
+
+ +
+
+
+
+

Process Soft Limit

+
+
+ +
+
+
+
+

Process Hard Limit

+
+
+ +
+
+
+
+

Persistent Connection

+
+
+ +
+
+ {$ persistStatus $} +
+
+
+ +
+
+
+

{% trans "Cannot fetch details. Error message:" %} {$ errorMessage $}

+
+
+

{% trans "Cannot tune. Error message:" %} {$ errorMessage $}

+
+
+

{% trans "Details Successfully fetched." %}

+
+
+

{% trans "PHP for " %}{$ phpVersionTuned + $} {% trans "Successfully tuned." %}

+
+
+
+
+
+
+ {% endif %} +{% endblock %} diff --git a/tuning/tuning.py b/tuning/tuning.py index 8afff2e2d..fb1dacc47 100755 --- a/tuning/tuning.py +++ b/tuning/tuning.py @@ -30,6 +30,11 @@ class tuningManager: None, 'admin') return proc.render() + def liteSpeedTuningV2(self, request, userID): + proc = httpProc(request, 'tuning/liteSpeedTuningV2.html', + None, 'admin') + return proc.render() + def phpTuning(self, request, userID): currentACL = ACLManager.loadedACL(userID) if ProcessUtilities.decideServer() == ProcessUtilities.OLS: @@ -44,6 +49,20 @@ class tuningManager: {'OLS': OLS}, 'admin') return proc.render() + def phpTuningV2(self, request, userID): + currentACL = ACLManager.loadedACL(userID) + if ProcessUtilities.decideServer() == ProcessUtilities.OLS: + websitesName = ACLManager.findAllSites(currentACL, userID) + OLS = 1 + proc = httpProc(request, 'tuning/phpTuning.html', + {'websiteList': websitesName, 'OLS': OLS}, 'admin') + return proc.render() + else: + OLS = 0 + proc = httpProc(request, 'tuning/phpTuningV2.html', + {'OLS': OLS}, 'admin') + return proc.render() + def tuneLitespeed(self, userID, data): try: @@ -171,4 +190,4 @@ class tuningManager: data_ret = {'fetch_status': 0, 'error_message': str(msg), 'tuneStatus': 0} logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [tunePHP]]") json_data = json.dumps(data_ret) - return HttpResponse(json_data) \ No newline at end of file + return HttpResponse(json_data) diff --git a/tuning/urls.py b/tuning/urls.py index 8eccf9958..beda4218c 100755 --- a/tuning/urls.py +++ b/tuning/urls.py @@ -1,14 +1,14 @@ -from django.conf.urls import url,include +from django.conf.urls import url, include from . import views urlpatterns = [ url(r'^$', views.loadTuningHome, name='loadTuningHome'), url(r'^litespeedTuning', views.liteSpeedTuning, name='liteSpeedTuning'), + url(r'^V2/litespeedTuningV2', views.liteSpeedTuningV2, name='liteSpeedTuningV2'), url(r'^phpTuning', views.phpTuning, name='phpTuning'), - - + url(r'^V2/phpTuningV2', views.phpTuningV2, name='phpTuningV2'), url(r'^tuneLitespeed', views.tuneLitespeed, name='tuneLitespeed'), url(r'^tunePHP', views.tunePHP, name='tunePHP'), -] \ No newline at end of file +] diff --git a/tuning/views.py b/tuning/views.py index 61d97ba27..26d350a76 100755 --- a/tuning/views.py +++ b/tuning/views.py @@ -4,6 +4,8 @@ from django.shortcuts import redirect import json from loginSystem.views import loadLoginPage from .tuning import tuningManager + + # Create your views here. @@ -15,6 +17,7 @@ def loadTuningHome(request): except KeyError: return redirect(loadLoginPage) + def liteSpeedTuning(request): try: userID = request.session['userID'] @@ -23,6 +26,16 @@ def liteSpeedTuning(request): except KeyError: return redirect(loadLoginPage) + +def liteSpeedTuningV2(request): + try: + userID = request.session['userID'] + tm = tuningManager() + return tm.liteSpeedTuningV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + def phpTuning(request): try: userID = request.session['userID'] @@ -31,6 +44,16 @@ def phpTuning(request): except KeyError: return redirect(loadLoginPage) + +def phpTuningV2(request): + try: + userID = request.session['userID'] + tm = tuningManager() + return tm.phpTuningV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + def tuneLitespeed(request): try: userID = request.session['userID'] @@ -39,10 +62,11 @@ def tuneLitespeed(request): except KeyError: return redirect(loadLoginPage) + def tunePHP(request): try: userID = request.session['userID'] tm = tuningManager() return tm.tunePHP(userID, json.loads(request.body)) except KeyError: - return redirect(loadLoginPage) \ No newline at end of file + return redirect(loadLoginPage)