From 32ba0332412a036d4f837d7bf3062eb3482a0ef0 Mon Sep 17 00:00:00 2001 From: usmannasir <01-134132-158@student.bahria.edu.pk> Date: Wed, 3 Oct 2018 18:46:44 +0500 Subject: [PATCH] Plugin Manager --- CyberCP/secMiddleware.py | 15 +- install/install.py | 4 +- plogical/backupManager.py | 4 +- plogical/pluginManagerGlobal.py | 18 +++ plogical/sslUtilities.py | 7 +- plogical/test.py | 45 ------ plogical/virtualHostUtilities.py | 4 +- userManagment/__init__.py | 1 + userManagment/apps.py | 3 + userManagment/signals.py | 7 + websiteFunctions/pluginManager.py | 124 +++++++++++++++++ websiteFunctions/signals.py | 93 +++++++++++++ websiteFunctions/views.py | 221 ++++++++++++++++++++++++++---- 13 files changed, 460 insertions(+), 86 deletions(-) create mode 100644 plogical/pluginManagerGlobal.py create mode 100644 userManagment/signals.py create mode 100644 websiteFunctions/pluginManager.py create mode 100644 websiteFunctions/signals.py diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py index 42234cc41..6c10f19d5 100644 --- a/CyberCP/secMiddleware.py +++ b/CyberCP/secMiddleware.py @@ -12,14 +12,23 @@ class secMiddleware: try: data = json.loads(request.body) for key, value in data.iteritems(): - if type(value) == int or type(value) == bool or key == 'configData': + if type(value) == str or type(value) == unicode: + pass + else: + continue + if key == 'configData' or key == 'rewriteRules' or key == 'modSecRules': continue if value.find(';') > -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1: logging.writeToFile(request.body) - return HttpResponse('Error') + final_dic = {'error_message': "Data supplied is not accepted.", + "errorMessage": "Data supplied is not accepted."} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) if key.find(';') > -1 or key.find('&&') > -1 or key.find('|') > -1 or key.find('...') > -1: logging.writeToFile(request.body) - return HttpResponse('Error') + final_dic = {'error_message': "Data supplied is not accepted.", "errorMessage": "Data supplied is not accepted."} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) except BaseException, msg: logging.writeToFile(str(msg)) response = self.get_response(request) diff --git a/install/install.py b/install/install.py index e4285521b..9eb342d99 100644 --- a/install/install.py +++ b/install/install.py @@ -687,7 +687,7 @@ class preFlightsChecks: count = 0 while (1): - command = "wget http://cyberpanel.net/CyberPanel.1.7.1.tar.gz" + command = "wget http://cyberpanel.net/CyberPanel.1.7.2.tar.gz" #command = "wget http://cyberpanel.net/CyberPanelTemp.tar.gz" res = subprocess.call(shlex.split(command)) @@ -707,7 +707,7 @@ class preFlightsChecks: count = 0 while(1): - command = "tar zxf CyberPanel.1.7.1.tar.gz" + command = "tar zxf CyberPanel.1.7.2.tar.gz" #command = "tar zxf CyberPanelTemp.tar.gz" res = subprocess.call(shlex.split(command)) diff --git a/plogical/backupManager.py b/plogical/backupManager.py index 5695d8ac9..28a94829d 100644 --- a/plogical/backupManager.py +++ b/plogical/backupManager.py @@ -140,7 +140,7 @@ class BackupManager: ## /home/example.com/backup/backup-example-06-50-03-Thu-Feb-2018 tempStoragePath = os.path.join(backupPath, backupName) - execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "sudo nice -n python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " submitBackupCreation --tempStoragePath " + tempStoragePath + " --backupName " \ + backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain @@ -290,7 +290,7 @@ class BackupManager: else: dir = "CyberPanelRestore" - execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" + execPath = "sudo nice -n python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py" execPath = execPath + " submitRestore --backupFile " + backupFile + " --dir " + dir subprocess.Popen(shlex.split(execPath)) time.sleep(4) diff --git a/plogical/pluginManagerGlobal.py b/plogical/pluginManagerGlobal.py new file mode 100644 index 000000000..8312fe509 --- /dev/null +++ b/plogical/pluginManagerGlobal.py @@ -0,0 +1,18 @@ +from django.http import HttpResponse +from CyberCPLogFileWriter import CyberCPLogFileWriter as logging + + +class pluginManagerGlobal: + @staticmethod + def globalPlug(request, eventInQuest): + hookReturn = eventInQuest.send(sender=None, request=request) + for items in hookReturn: + if type(items[1] == HttpResponse): + return items[1] + else: + if items[1] == 200: + return items[1] + else: + logging.writeToFile('Something wrong with : ' + str(items[0]) + ' on ' + str(eventInQuest)) + return 200 + return 200 \ No newline at end of file diff --git a/plogical/sslUtilities.py b/plogical/sslUtilities.py index cf1be9242..4570c3fe8 100644 --- a/plogical/sslUtilities.py +++ b/plogical/sslUtilities.py @@ -294,10 +294,9 @@ def issueSSLForDomain(domain, adminEmail, sslpath, aliasDomain = None): else: return [0, "210 Failed to install SSL for domain. [issueSSLForDomain]"] else: - pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + domain - - if not os.path.exists(pathToStoreSSL): - os.mkdir(pathToStoreSSL) + pathToStoreSSL = "/etc/letsencrypt/live/" + domain + command = 'mkdir -p ' + pathToStoreSSL + subprocess.call(shlex.split(command)) pathToStoreSSLPrivKey = "/etc/letsencrypt/live/" + domain + "/privkey.pem" pathToStoreSSLFullChain = "/etc/letsencrypt/live/" + domain + "/fullchain.pem" diff --git a/plogical/test.py b/plogical/test.py index 3e0606949..e69de29bb 100644 --- a/plogical/test.py +++ b/plogical/test.py @@ -1,45 +0,0 @@ -import sys -import subprocess -import shutil -import argparse -import os -import shlex -import time -import string -import random - -def setupVirtualEnv(): - ## - - - command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" - res = subprocess.call(shlex.split(command)) - - ## - - - command = "pip install virtualenv" - res = subprocess.call(shlex.split(command)) - - #### - - command = "virtualenv /usr/local/CyberCP" - res = subprocess.call(shlex.split(command)) - - ## - env_path = '/usr/local/CyberCP' - if not os.path.exists(env_path): - subprocess.call(['virtualenv', env_path]) - activate_this = os.path.join(env_path, 'bin', 'activate_this.py') - execfile(activate_this, dict(__file__=activate_this)) - - command = "pip install -r /usr/local/CyberCP/requirments.txt" - res = subprocess.call(shlex.split(command)) - - ## - - command = "systemctl restart gunicorn.socket" - res = subprocess.call(shlex.split(command)) - - -setupVirtualEnv() \ No newline at end of file diff --git a/plogical/virtualHostUtilities.py b/plogical/virtualHostUtilities.py index cd48b583a..04369d23c 100644 --- a/plogical/virtualHostUtilities.py +++ b/plogical/virtualHostUtilities.py @@ -736,8 +736,8 @@ class virtualHostUtilities: pathToStoreSSL = '/etc/letsencrypt/live/' + virtualHost - if not os.path.exists(pathToStoreSSL): - os.mkdir(pathToStoreSSL) + command = 'mkdir -p ' + pathToStoreSSL + subprocess.call(shlex.split(command)) pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem" pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem" diff --git a/userManagment/__init__.py b/userManagment/__init__.py index e69de29bb..ea1f3affe 100644 --- a/userManagment/__init__.py +++ b/userManagment/__init__.py @@ -0,0 +1 @@ +default_app_config = 'userManagment.apps.UsermanagmentConfig' \ No newline at end of file diff --git a/userManagment/apps.py b/userManagment/apps.py index a4cc35103..cb94ead28 100644 --- a/userManagment/apps.py +++ b/userManagment/apps.py @@ -6,3 +6,6 @@ from django.apps import AppConfig class UsermanagmentConfig(AppConfig): name = 'userManagment' + + def ready(self): + import signals diff --git a/userManagment/signals.py b/userManagment/signals.py new file mode 100644 index 000000000..b5100775e --- /dev/null +++ b/userManagment/signals.py @@ -0,0 +1,7 @@ +from django.dispatch import receiver +from websiteFunctions.signals import postWebsiteDeletion + +@receiver(postWebsiteDeletion) +def rcvr(sender, **kwargs): + request = kwargs['request'] + return 200 diff --git a/websiteFunctions/pluginManager.py b/websiteFunctions/pluginManager.py new file mode 100644 index 000000000..98459f0d2 --- /dev/null +++ b/websiteFunctions/pluginManager.py @@ -0,0 +1,124 @@ +from signals import * +from plogical.pluginManagerGlobal import pluginManagerGlobal + +class pluginManager: + + @staticmethod + def preWebsiteCreation(request): + return pluginManagerGlobal.globalPlug(request, preWebsiteCreation) + + @staticmethod + def postWebsiteCreation(request): + return pluginManagerGlobal.globalPlug(request, postWebsiteCreation) + + @staticmethod + def preDomainCreation(request): + return pluginManagerGlobal.globalPlug(request, preDomainCreation) + + @staticmethod + def postDomainCreation(request): + return pluginManagerGlobal.globalPlug(request, postDomainCreation) + + @staticmethod + def preWebsiteDeletion(request): + return pluginManagerGlobal.globalPlug(request, preWebsiteDeletion) + + @staticmethod + def postWebsiteDeletion(request): + return pluginManagerGlobal.globalPlug(request, postWebsiteDeletion) + + @staticmethod + def preDomainDeletion(request): + return pluginManagerGlobal.globalPlug(request, preDomainDeletion) + + @staticmethod + def postDomainDeletion(request): + return pluginManagerGlobal.globalPlug(request, postDomainDeletion) + + @staticmethod + def preWebsiteSuspension(request): + return pluginManagerGlobal.globalPlug(request, preWebsiteSuspension) + + @staticmethod + def postWebsiteSuspension(request): + return pluginManagerGlobal.globalPlug(request, postWebsiteSuspension) + + @staticmethod + def preWebsiteModification(request): + return pluginManagerGlobal.globalPlug(request, preWebsiteModification) + + @staticmethod + def postWebsiteModification(request): + return pluginManagerGlobal.globalPlug(request, postWebsiteModification) + + @staticmethod + def preSaveConfigsToFile(request): + return pluginManagerGlobal.globalPlug(request, preSaveConfigsToFile) + + @staticmethod + def postSaveConfigsToFile(request): + return pluginManagerGlobal.globalPlug(request, postSaveConfigsToFile) + + @staticmethod + def preSaveRewriteRules(request): + return pluginManagerGlobal.globalPlug(request, preSaveRewriteRules) + + @staticmethod + def postSaveRewriteRules(request): + return pluginManagerGlobal.globalPlug(request, postSaveRewriteRules) + + @staticmethod + def preSaveSSL(request): + return pluginManagerGlobal.globalPlug(request, preSaveSSL) + + @staticmethod + def postSaveSSL(request): + return pluginManagerGlobal.globalPlug(request, postSaveSSL) + + @staticmethod + def preChangePHP(request): + return pluginManagerGlobal.globalPlug(request, preChangePHP) + + @staticmethod + def postChangePHP(request): + return pluginManagerGlobal.globalPlug(request, postChangePHP) + + @staticmethod + def preChangeOpenBasedir(request): + return pluginManagerGlobal.globalPlug(request, preChangeOpenBasedir) + + @staticmethod + def postChangeOpenBasedir(request): + return pluginManagerGlobal.globalPlug(request, postChangeOpenBasedir) + + @staticmethod + def preAddNewCron(request): + return pluginManagerGlobal.globalPlug(request, preAddNewCron) + + @staticmethod + def postAddNewCron(request): + return pluginManagerGlobal.globalPlug(request, postAddNewCron) + + @staticmethod + def preRemCronbyLine(request): + return pluginManagerGlobal.globalPlug(request, preRemCronbyLine) + + @staticmethod + def postRemCronbyLine(request): + return pluginManagerGlobal.globalPlug(request, postRemCronbyLine) + + @staticmethod + def preSubmitAliasCreation(request): + return pluginManagerGlobal.globalPlug(request, preSubmitAliasCreation) + + @staticmethod + def postSubmitAliasCreation(request): + return pluginManagerGlobal.globalPlug(request, postSubmitAliasCreation) + + @staticmethod + def preDelateAlias(request): + return pluginManagerGlobal.globalPlug(request, preDelateAlias) + + @staticmethod + def postDelateAlias(request): + return pluginManagerGlobal.globalPlug(request, postDelateAlias) \ No newline at end of file diff --git a/websiteFunctions/signals.py b/websiteFunctions/signals.py new file mode 100644 index 000000000..e7041edc3 --- /dev/null +++ b/websiteFunctions/signals.py @@ -0,0 +1,93 @@ +# The world is a prison for the believer. + +from django.dispatch import Signal + +## This event is fired before CyberPanel core start creation of website +preWebsiteCreation = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished creation of website. +postWebsiteCreation = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start creation of child-domain +preDomainCreation = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished creation of child-domain. +postDomainCreation = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start deletion of website +preWebsiteDeletion = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished deletion of website +postWebsiteDeletion = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start deletion of child-domain +preDomainDeletion = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished deletion of child-domain +postDomainDeletion = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start suspension of website +preWebsiteSuspension = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished suspension of website +postWebsiteSuspension = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start suspension of website +preWebsiteModification = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished suspension of website +postWebsiteModification = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start saving changes to vhost conf +preSaveConfigsToFile = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished saving changes to vhost conf +postSaveConfigsToFile = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start saving changes to vhost rewrite file +preSaveRewriteRules = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished saving changes to vhost rewrite file +postSaveRewriteRules = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start saving custom SSL +preSaveSSL = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished saving saving custom SSL +postSaveSSL = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start changing php version of domain or website +preChangePHP = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished change php version of domain or website +postChangePHP = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start changing open_basdir status for domain or website +preChangeOpenBasedir = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core finished changing open_basdir status for domain or website +postChangeOpenBasedir = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start adding new cron +preAddNewCron = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core is finished adding new cron +postAddNewCron = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start removing cron +preRemCronbyLine = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core is finished removing cron +postRemCronbyLine = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start creating domain alias +preSubmitAliasCreation = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core is finished creating domain alias +postSubmitAliasCreation = Signal(providing_args=["request"]) + +## This event is fired before CyberPanel core start deleting domain alais +preDelateAlias = Signal(providing_args=["request"]) + +## This event is fired after CyberPanel core is finished deleting domain alias +postDelateAlias = Signal(providing_args=["request"]) \ No newline at end of file diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index f15598c12..cda477e19 100644 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -8,6 +8,7 @@ from loginSystem.views import loadLoginPage import plogical.CyberCPLogFileWriter as logging import json from plogical.website import WebsiteManager +from websiteFunctions.pluginManager import pluginManager def loadWebsitesHome(request): try: @@ -63,16 +64,40 @@ def listWebsites(request): def submitWebsiteCreation(request): try: userID = request.session['userID'] + + result = pluginManager.preWebsiteCreation(request) + + if result != 200: + return result + wm = WebsiteManager() - return wm.submitWebsiteCreation(userID, json.loads(request.body)) + coreResult = wm.submitWebsiteCreation(userID, json.loads(request.body)) + + result = pluginManager.postWebsiteCreation(request) + if result != 200: + return result + + return coreResult + except KeyError: return redirect(loadLoginPage) def submitDomainCreation(request): try: userID = request.session['userID'] + + result = pluginManager.preDomainCreation(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.submitDomainCreation(userID, json.loads(request.body)) + coreResult = wm.submitDomainCreation(userID, json.loads(request.body)) + + result = pluginManager.postDomainCreation(request) + if result != 200: + return result + + return coreResult except KeyError: return redirect(loadLoginPage) @@ -94,11 +119,20 @@ def getFurtherAccounts(request): def submitWebsiteDeletion(request): try: - userID = request.session['userID'] - wm = WebsiteManager() - return wm.submitWebsiteDeletion(userID, json.loads(request.body)) + result = pluginManager.preWebsiteDeletion(request) + if result != 200: + return result + + wm = WebsiteManager() + coreResult = wm.submitWebsiteDeletion(userID, json.loads(request.body)) + + result = pluginManager.postWebsiteDeletion(request) + if result != 200: + return result + + return coreResult except KeyError: return redirect(loadLoginPage) @@ -106,8 +140,19 @@ def submitDomainDeletion(request): try: userID = request.session['userID'] + + result = pluginManager.preDomainDeletion(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.submitDomainDeletion(userID, json.loads(request.body)) + coreResult = wm.submitDomainDeletion(userID, json.loads(request.body)) + + result = pluginManager.postDomainDeletion(request) + if result != 200: + return result + + return coreResult except KeyError: return redirect(loadLoginPage) @@ -116,8 +161,19 @@ def submitWebsiteStatus(request): try: userID = request.session['userID'] + + result = pluginManager.preWebsiteSuspension(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.submitWebsiteStatus(userID, json.loads(request.body)) + coreResult = wm.submitWebsiteStatus(userID, json.loads(request.body)) + + result = pluginManager.postWebsiteSuspension(request) + if result != 200: + return result + + return coreResult except KeyError: return redirect(loadLoginPage) @@ -136,8 +192,19 @@ def saveWebsiteChanges(request): try: userID = request.session['userID'] + + result = pluginManager.preWebsiteModification(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.saveWebsiteChanges(userID, json.loads(request.body)) + coreResult = wm.saveWebsiteChanges(userID, json.loads(request.body)) + + result = pluginManager.postWebsiteModification(request) + if result != 200: + return result + + return coreResult except KeyError: return redirect(loadLoginPage) @@ -186,9 +253,22 @@ def getDataFromConfigFile(request): def saveConfigsToFile(request): try: + userID = request.session['userID'] + + result = pluginManager.preSaveConfigsToFile(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.saveConfigsToFile(userID, json.loads(request.body)) + coreResult = wm.saveConfigsToFile(userID, json.loads(request.body)) + + result = pluginManager.postSaveConfigsToFile(request) + if result != 200: + return result + + return coreResult + except KeyError: return redirect(loadLoginPage) @@ -202,25 +282,64 @@ def getRewriteRules(request): def saveRewriteRules(request): try: + userID = request.session['userID'] + + result = pluginManager.preSaveRewriteRules(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.saveRewriteRules(userID, json.loads(request.body)) + coreResult = wm.saveRewriteRules(userID, json.loads(request.body)) + + result = pluginManager.postSaveRewriteRules(request) + if result != 200: + return result + + return coreResult + except KeyError: return redirect(loadLoginPage) def saveSSL(request): try: + userID = request.session['userID'] + + result = pluginManager.preSaveSSL(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.saveSSL(userID, json.loads(request.body)) + coreResult = wm.saveSSL(userID, json.loads(request.body)) + + result = pluginManager.postSaveSSL(request) + if result != 200: + return result + + return coreResult + except KeyError: return redirect(loadLoginPage) def changePHP(request): try: + userID = request.session['userID'] + + result = pluginManager.preChangePHP(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.changePHP(userID, json.loads(request.body)) + coreResult = wm.changePHP(userID, json.loads(request.body)) + + result = pluginManager.postChangePHP(request) + if result != 200: + return result + + return coreResult + except KeyError: return redirect(loadLoginPage) @@ -259,16 +378,38 @@ def saveCronChanges(request): def remCronbyLine(request): try: userID = request.session['userID'] + + result = pluginManager.preRemCronbyLine(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.remCronbyLine(userID, json.loads(request.body)) + coreResult = wm.remCronbyLine(userID, json.loads(request.body)) + + result = pluginManager.postRemCronbyLine(request) + if result != 200: + return result + + return coreResult except KeyError: return redirect(loadLoginPage) def addNewCron(request): try: userID = request.session['userID'] + + result = pluginManager.preAddNewCron(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.addNewCron(userID, json.loads(request.body)) + coreResult = wm.addNewCron(userID, json.loads(request.body)) + + result = pluginManager.postAddNewCron(request) + if result != 200: + return result + + return coreResult except KeyError: return redirect(loadLoginPage) @@ -283,8 +424,19 @@ def domainAlias(request, domain): def submitAliasCreation(request): try: userID = request.session['userID'] + + result = pluginManager.preSubmitAliasCreation(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.submitAliasCreation(userID, json.loads(request.body)) + coreResult = wm.submitAliasCreation(userID, json.loads(request.body)) + + result = pluginManager.postSubmitAliasCreation(request) + if result != 200: + return result + + return coreResult except KeyError: return redirect(loadLoginPage) @@ -299,27 +451,40 @@ def issueAliasSSL(request): def delateAlias(request): try: userID = request.session['userID'] + + result = pluginManager.preDelateAlias(request) + if result != 200: + return result + wm = WebsiteManager() - return wm.delateAlias(userID, json.loads(request.body)) + coreResult = wm.delateAlias(userID, json.loads(request.body)) + + result = pluginManager.postDelateAlias(request) + if result != 200: + return result + + return coreResult except KeyError: return redirect(loadLoginPage) def changeOpenBasedir(request): try: - userID = request.session['userID'] - wm = WebsiteManager() - return wm.changeOpenBasedir(userID, json.loads(request.body)) - except KeyError: - return redirect(loadLoginPage) -def applicationInstaller(request): - try: userID = request.session['userID'] - try: - return render(request, 'websiteFunctions/applicationInstaller.html') - except BaseException, msg: - logging.CyberCPLogFileWriter.writeToFile(str(msg)) - return HttpResponse(str(msg)) + + result = pluginManager.preChangeOpenBasedir(request) + if result != 200: + return result + + wm = WebsiteManager() + coreResult = wm.changeOpenBasedir(userID, json.loads(request.body)) + + result = pluginManager.postChangeOpenBasedir(request) + if result != 200: + return result + + return coreResult + except KeyError: return redirect(loadLoginPage)