mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
add default renderer to websites
This commit is contained in:
@@ -4,6 +4,8 @@ import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
@@ -39,7 +41,8 @@ class BackupManager:
|
||||
def loadBackupHome(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
return render(request, 'backup/index.html', currentACL)
|
||||
proc = httpProc(request, 'backup/index.html', currentACL)
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -51,7 +54,8 @@ class BackupManager:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
return render(request, 'backup/backup.html', {'websiteList': websitesName})
|
||||
proc = httpProc(request, 'backup/backup.html', {'websiteList': websitesName})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -73,7 +77,8 @@ class BackupManager:
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'backup/googleDrive.html', {'accounts': gDriveAcctsList, 'websites': websitesName})
|
||||
proc = httpProc(request, 'backup/googleDrive.html', {'accounts': gDriveAcctsList, 'websites': websitesName})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -365,7 +370,8 @@ class BackupManager:
|
||||
path = os.path.join("/home", "backup")
|
||||
|
||||
if not os.path.exists(path):
|
||||
return render(request, 'backup/restore.html')
|
||||
proc = httpProc(request, 'backup/restore.html')
|
||||
return proc.render()
|
||||
else:
|
||||
all_files = []
|
||||
ext = ".tar.gz"
|
||||
@@ -378,7 +384,8 @@ class BackupManager:
|
||||
if filename.endswith(ext):
|
||||
all_files.append(filename)
|
||||
|
||||
return render(request, 'backup/restore.html', {'backups': all_files})
|
||||
proc = httpProc(request, 'backup/restore.html', {'backups': all_files})
|
||||
return proc.render()
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
@@ -701,7 +708,8 @@ class BackupManager:
|
||||
if ACLManager.currentContextPermission(currentACL, 'addDeleteDestinations') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'backup/backupDestinations.html', {})
|
||||
proc = httpProc(request, 'backup/backupDestinations.html', {})
|
||||
return proc.render()
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
@@ -883,7 +891,8 @@ class BackupManager:
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'backup/backupSchedule.html', {'destinations': dests, 'websites': websitesName})
|
||||
proc = httpProc(request, 'backup/backupSchedule.html', {'destinations': dests, 'websites': websitesName})
|
||||
return proc.render()
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
@@ -1015,7 +1024,8 @@ class BackupManager:
|
||||
if ACLManager.currentContextPermission(currentACL, 'remoteBackups') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'backup/remoteBackups.html')
|
||||
proc = httpProc(request, 'backup/remoteBackups.html')
|
||||
return proc.render()
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
@@ -1386,7 +1396,8 @@ class BackupManager:
|
||||
for logFile in logFiles:
|
||||
all_files.append(logFile.logFile)
|
||||
|
||||
return render(request, 'backup/backupLogs.html', {'backups': all_files})
|
||||
proc = httpProc(request, 'backup/backupLogs.html', {'backups': all_files})
|
||||
return proc.render()
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -27,7 +27,7 @@ import requests
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
import threading as multi
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
# Use default socket to connect
|
||||
class ContainerManager(multi.Thread):
|
||||
@@ -50,7 +50,8 @@ class ContainerManager(multi.Thread):
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(self.request, self.templateName, self.data)
|
||||
proc = httpProc(self.request, self.templateName, self.data)
|
||||
return proc.render()
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
@@ -111,9 +112,10 @@ class ContainerManager(multi.Thread):
|
||||
except docker.errors.ImageNotFound:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
return render(request, 'dockerManager/images.html', {"type": admin.type,
|
||||
proc = httpProc(request, 'dockerManager/images.html', {"type": admin.type,
|
||||
'image': image,
|
||||
'tag': tag})
|
||||
return proc.render()
|
||||
|
||||
envList = {};
|
||||
if 'Env' in inspectImage['Config']:
|
||||
|
||||
@@ -5,8 +5,6 @@ from django.shortcuts import render,redirect
|
||||
from django.http import HttpResponse
|
||||
from mailServer.models import Domains, EUsers
|
||||
# Create your views here.
|
||||
from loginSystem.models import Administrator
|
||||
from plogical.httpProc import httpProc
|
||||
from websiteFunctions.models import Websites
|
||||
from loginSystem.views import loadLoginPage
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
@@ -20,7 +18,7 @@ from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from random import randint
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
# Create your views here.
|
||||
|
||||
## Email Policy Server
|
||||
@@ -157,7 +155,8 @@ def listDomains(request):
|
||||
break
|
||||
|
||||
if installCheck == 0:
|
||||
return render(request, 'emailPremium/listDomains.html', {"installCheck": installCheck})
|
||||
proc = httpProc(request, 'emailPremium/listDomains.html', {"installCheck": installCheck})
|
||||
return proc.render()
|
||||
|
||||
###
|
||||
|
||||
@@ -962,7 +961,8 @@ def fetchSpamAssassinSettings(request):
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
return render(request,'managePHP/editPHPConfig.html')
|
||||
proc = httpProc(request,'managePHP/editPHPConfig.html')
|
||||
return proc.render()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2333
plogical/website.py
2333
plogical/website.py
File diff suppressed because it is too large
Load Diff
@@ -1,22 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.shortcuts import render,redirect
|
||||
from django.shortcuts import redirect
|
||||
from django.http import HttpResponse
|
||||
from loginSystem.models import Administrator
|
||||
from loginSystem.views import loadLoginPage
|
||||
import json
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
from websiteFunctions.pluginManager import pluginManager
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
def loadWebsitesHome(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
return render(request,'websiteFunctions/index.html',{"type":admin.type})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'websiteFunctions/index.html',
|
||||
{"type": admin.type})
|
||||
return proc.render()
|
||||
|
||||
def createWebsite(request):
|
||||
try:
|
||||
|
||||
@@ -4,6 +4,8 @@ import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
@@ -53,15 +55,14 @@ class WebsiteManager:
|
||||
def createWebsite(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'createWebsite') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
adminNames = ACLManager.loadAllUsers(userID)
|
||||
packagesName = ACLManager.loadPackages(userID, currentACL)
|
||||
phps = PHPManager.findPHPVersions()
|
||||
|
||||
Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
|
||||
return render(request, 'websiteFunctions/createWebsite.html', Data)
|
||||
proc = httpProc(request, 'websiteFunctions/createWebsite.html',
|
||||
Data, 'createWebsite')
|
||||
return proc.render()
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
@@ -71,25 +72,22 @@ class WebsiteManager:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'modifyWebsite') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
phps = PHPManager.findPHPVersions()
|
||||
|
||||
return render(request, 'websiteFunctions/modifyWebsite.html', {'websiteList': websitesName, 'phps': phps})
|
||||
proc = httpProc(request, 'websiteFunctions/modifyWebsite.html',
|
||||
{'websiteList': websitesName, 'phps': phps}, 'modifyWebsite')
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def deleteWebsite(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'deleteWebsite') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'websiteFunctions/deleteWebsite.html', {'websiteList': websitesName})
|
||||
proc = httpProc(request, 'websiteFunctions/deleteWebsite.html',
|
||||
{'websiteList': websitesName}, 'deleteWebsite')
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -97,12 +95,12 @@ class WebsiteManager:
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'suspendWebsite') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'websiteFunctions/suspendWebsite.html', {'websiteList': websitesName})
|
||||
proc = httpProc(request, 'websiteFunctions/suspendWebsite.html',
|
||||
{'websiteList': websitesName}, 'suspendWebsite')
|
||||
return proc.render()
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -110,8 +108,9 @@ class WebsiteManager:
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
pagination = self.websitePagination(currentACL, userID)
|
||||
|
||||
return render(request, 'websiteFunctions/listWebsites.html', {"pagination": pagination})
|
||||
proc = httpProc(request, 'websiteFunctions/listWebsites.html',
|
||||
{"pagination": pagination})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -124,8 +123,9 @@ class WebsiteManager:
|
||||
phps = PHPManager.findPHPVersions()
|
||||
|
||||
Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps}
|
||||
|
||||
return render(request, 'websiteFunctions/listChildDomains.html', Data)
|
||||
proc = httpProc(request, 'websiteFunctions/listChildDomains.html',
|
||||
Data)
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -140,7 +140,9 @@ class WebsiteManager:
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'websiteFunctions/listCron.html', {'domain': request.GET.get('domain')})
|
||||
proc = httpProc(request, 'websiteFunctions/listCron.html',
|
||||
{'domain': request.GET.get('domain')})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -159,12 +161,13 @@ class WebsiteManager:
|
||||
|
||||
path = "/home/" + self.domain + "/public_html"
|
||||
|
||||
return render(request, 'websiteFunctions/domainAlias.html', {
|
||||
proc = httpProc(request, 'websiteFunctions/domainAlias.html', {
|
||||
'masterDomain': self.domain,
|
||||
'aliases': finalAlisList,
|
||||
'path': path,
|
||||
'noAlias': noAlias
|
||||
})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -891,11 +894,12 @@ class WebsiteManager:
|
||||
else:
|
||||
Data['ftp'] = 0
|
||||
|
||||
return render(request, 'websiteFunctions/website.html', Data)
|
||||
|
||||
proc = httpProc(request, 'websiteFunctions/website.html', Data)
|
||||
return proc.render()
|
||||
else:
|
||||
return render(request, 'websiteFunctions/website.html',
|
||||
proc = httpProc(request, 'websiteFunctions/website.html',
|
||||
{"error": 1, "domain": "This domain does not exists."})
|
||||
return proc.render()
|
||||
|
||||
def launchChild(self, request=None, userID=None, data=None):
|
||||
|
||||
@@ -976,11 +980,12 @@ class WebsiteManager:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
||||
|
||||
return render(request, 'websiteFunctions/launchChild.html', Data)
|
||||
proc = httpProc(request, 'websiteFunctions/launchChild.html', Data)
|
||||
return proc.render()
|
||||
else:
|
||||
return render(request, 'websiteFunctions/launchChild.html',
|
||||
proc = httpProc(request, 'websiteFunctions/launchChild.html',
|
||||
{"error": 1, "domain": "This child domain does not exists"})
|
||||
|
||||
return proc.render()
|
||||
def getDataFromLogFile(self, userID=None, data=None):
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -1774,8 +1779,8 @@ class WebsiteManager:
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'websiteFunctions/installWordPress.html', {'domainName': self.domain})
|
||||
|
||||
proc = httpProc(request, 'websiteFunctions/installWordPress.html', {'domainName': self.domain})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -1879,7 +1884,8 @@ class WebsiteManager:
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'websiteFunctions/installJoomla.html', {'domainName': self.domain})
|
||||
proc = httpProc(request, 'websiteFunctions/installJoomla.html', {'domainName': self.domain})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -1951,8 +1957,9 @@ class WebsiteManager:
|
||||
|
||||
webhookURL = 'https://' + ipAddress + ':%s/websites/' % (port) + self.domain + '/gitNotify'
|
||||
|
||||
return render(request, 'websiteFunctions/setupGit.html',
|
||||
proc = httpProc(request, 'websiteFunctions/setupGit.html',
|
||||
{'domainName': self.domain, 'installed': 1, 'webhookURL': webhookURL})
|
||||
return proc.render()
|
||||
else:
|
||||
|
||||
command = "ssh-keygen -f /home/%s/.ssh/%s -t rsa -N ''" % (self.domain, website.externalApp)
|
||||
@@ -1979,8 +1986,9 @@ StrictHostKeyChecking no
|
||||
command = 'cat /home/%s/.ssh/%s.pub' % (self.domain, website.externalApp)
|
||||
deploymentKey = ProcessUtilities.outputExecutioner(command, website.externalApp)
|
||||
|
||||
return render(request, 'websiteFunctions/setupGit.html',
|
||||
proc = httpProc(request, 'websiteFunctions/setupGit.html',
|
||||
{'domainName': self.domain, 'deploymentKey': deploymentKey, 'installed': 0})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -2118,7 +2126,8 @@ StrictHostKeyChecking no
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'websiteFunctions/installPrestaShop.html', {'domainName': self.domain})
|
||||
proc = httpProc(request, 'websiteFunctions/installPrestaShop.html', {'domainName': self.domain})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -2132,7 +2141,8 @@ StrictHostKeyChecking no
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'websiteFunctions/installMagento.html', {'domainName': self.domain})
|
||||
proc = httpProc(request, 'websiteFunctions/installMagento.html', {'domainName': self.domain})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -2193,7 +2203,8 @@ StrictHostKeyChecking no
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'websiteFunctions/installMautic.html', {'domainName': self.domain})
|
||||
proc = httpProc(request, 'websiteFunctions/installMautic.html', {'domainName': self.domain})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -2616,8 +2627,9 @@ StrictHostKeyChecking no
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
externalApp = website.externalApp
|
||||
|
||||
return render(request, 'websiteFunctions/sshAccess.html',
|
||||
proc = httpProc(request, 'websiteFunctions/sshAccess.html',
|
||||
{'domainName': self.domain, 'externalApp': externalApp})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -2673,8 +2685,9 @@ StrictHostKeyChecking no
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
externalApp = website.externalApp
|
||||
|
||||
return render(request, 'websiteFunctions/setupStaging.html',
|
||||
proc = httpProc(request, 'websiteFunctions/setupStaging.html',
|
||||
{'domainName': self.domain, 'externalApp': externalApp})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -2741,8 +2754,9 @@ StrictHostKeyChecking no
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
externalApp = website.externalApp
|
||||
|
||||
return render(request, 'websiteFunctions/syncMaster.html',
|
||||
proc = httpProc(request, 'websiteFunctions/syncMaster.html',
|
||||
{'domainName': self.domain, 'externalApp': externalApp, 'childDomain': childDomain})
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
@@ -2855,9 +2869,9 @@ StrictHostKeyChecking no
|
||||
basePath = '/var/lib/mysql/'
|
||||
folders.append('%s%s' % (basePath, database.dbName))
|
||||
|
||||
return render(request, 'websiteFunctions/manageGIT.html',
|
||||
proc = httpProc(request, 'websiteFunctions/manageGIT.html',
|
||||
{'domainName': self.domain, 'folders': folders})
|
||||
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user