push changes

This commit is contained in:
Michael Ramsey
2019-10-08 10:53:02 -04:00
parent 0695e9c9d0
commit bd71b39d31
1802 changed files with 170876 additions and 50904 deletions

View File

@@ -0,0 +1,682 @@
#!/usr/local/CyberCP/bin/python2
import os.path
import sys
import django
sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
django.setup()
from django.shortcuts import render,redirect
from django.http import HttpResponse
from models import Domains,EUsers
from loginSystem.views import loadLoginPage
import plogical.CyberCPLogFileWriter as logging
import json
import shlex
import subprocess
from plogical.virtualHostUtilities import virtualHostUtilities
from plogical.mailUtilities import mailUtilities
import thread
from dns.models import Domains as dnsDomains
from dns.models import Records as dnsRecords
from mailServer.models import Forwardings
from plogical.acl import ACLManager
import os
from plogical.dnsUtilities import DNS
from loginSystem.models import Administrator
from plogical.processUtilities import ProcessUtilities
import bcrypt
class MailServerManager:
def __init__(self, request = None):
self.request = request
def loadEmailHome(self):
try:
val = self.request.session['userID']
return render(self.request, 'mailServer/index.html')
except KeyError:
return redirect(loadLoginPage)
def createEmailAccount(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'createEmail') == 0:
return ACLManager.loadError()
if not os.path.exists('/home/cyberpanel/postfix'):
return render(self.request, "mailServer/createEmailAccount.html", {"status": 0})
websitesName = ACLManager.findAllSites(currentACL, userID)
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
return render(self.request, 'mailServer/createEmailAccount.html',
{'websiteList': websitesName, "status": 1})
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return HttpResponse(str(msg))
def listEmails(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'listEmails') == 0:
return ACLManager.loadError()
if not os.path.exists('/home/cyberpanel/postfix'):
return render(self.request, "mailServer/listEmails.html", {"status": 0})
websitesName = ACLManager.findAllSites(currentACL, userID)
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
return render(self.request, 'mailServer/listEmails.html',
{'websiteList': websitesName, "status": 1})
except BaseException, msg:
return redirect(loadLoginPage)
def submitEmailCreation(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'createEmail') == 0:
return ACLManager.loadErrorJson('createEmailStatus', 0)
data = json.loads(self.request.body)
domainName = data['domain']
userName = data['username']
password = data['passwordByPass']
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(domainName, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
## Create email entry
result = mailUtilities.createEmailAccount(domainName, userName, password)
if result[0] == 1:
data_ret = {'status': 1, 'createEmailStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'status': 0, 'createEmailStatus': 0, 'error_message': result[1]}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'status': 0, 'createEmailStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def deleteEmailAccount(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'deleteEmail') == 0:
return ACLManager.loadError()
if not os.path.exists('/home/cyberpanel/postfix'):
return render(self.request, "mailServer/deleteEmailAccount.html", {"status": 0})
websitesName = ACLManager.findAllSites(currentACL, userID)
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
return render(self.request, 'mailServer/deleteEmailAccount.html',
{'websiteList': websitesName, "status": 1})
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return HttpResponse(str(msg))
def getEmailsForDomain(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'deleteEmail') == 0:
return ACLManager.loadErrorJson('fetchStatus', 0)
data = json.loads(self.request.body)
domain = data['domain']
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
try:
domain = Domains.objects.get(domain=domain)
except:
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': "No email accounts exists!"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
emails = domain.eusers_set.all()
if emails.count() == 0:
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': "No email accounts exists!"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
json_data = "["
checker = 0
count = 1
for items in emails:
dic = {'id': count, 'email': items.email}
count = count + 1
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)
json_data = json_data + ']'
final_dic = {'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def submitEmailDeletion(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'deleteEmail') == 0:
return ACLManager.loadErrorJson('deleteEmailStatus', 0)
data = json.loads(self.request.body)
email = data['email']
eUser = EUsers.objects.get(email=email)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(eUser.emailOwner.domainOwner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
mailUtilities.deleteEmailAccount(email)
data_ret = {'status': 1, 'deleteEmailStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'status': 0, 'deleteEmailStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def emailForwarding(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'emailForwarding') == 0:
return ACLManager.loadError()
if not os.path.exists('/home/cyberpanel/postfix'):
return render(self.request, "mailServer/emailForwarding.html", {"status": 0})
websitesName = ACLManager.findAllSites(currentACL, userID)
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
return render(self.request, 'mailServer/emailForwarding.html', {'websiteList': websitesName, "status": 1})
except BaseException, msg:
return HttpResponse(str(msg))
def fetchCurrentForwardings(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'emailForwarding') == 0:
return ACLManager.loadErrorJson('fetchStatus', 0)
data = json.loads(self.request.body)
emailAddress = data['emailAddress']
eUser = EUsers.objects.get(email=emailAddress)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(eUser.emailOwner.domainOwner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
currentForwardings = Forwardings.objects.filter(source=emailAddress)
json_data = "["
checker = 0
id = 1
for items in currentForwardings:
if items.source == items.destination:
continue
dic = {'id': id,
'source': items.source,
'destination': items.destination}
id = id + 1
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)
json_data = json_data + ']'
final_dic = {'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def submitForwardDeletion(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'emailForwarding') == 0:
return ACLManager.loadErrorJson('deleteForwardingStatus', 0)
data = json.loads(self.request.body)
destination = data['destination']
source = data['source']
eUser = EUsers.objects.get(email=source)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(eUser.emailOwner.domainOwner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
for items in Forwardings.objects.filter(destination=destination, source=source):
items.delete()
data_ret = {'status': 1, 'deleteForwardingStatus': 1, 'error_message': "None",
'successMessage': 'Successfully deleted!'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'status': 0, 'deleteForwardingStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def submitEmailForwardingCreation(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'emailForwarding') == 0:
return ACLManager.loadErrorJson('createStatus', 0)
data = json.loads(self.request.body)
source = data['source']
destination = data['destination']
eUser = EUsers.objects.get(email=source)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(eUser.emailOwner.domainOwner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
if Forwardings.objects.filter(source=source, destination=destination).count() > 0:
data_ret = {'status': 0, 'createStatus': 0,
'error_message': "You have already forwared to this destination."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
if Forwardings.objects.filter(source=source).count() == 0:
forwarding = Forwardings(source=source, destination=source)
forwarding.save()
forwarding = Forwardings(source=source, destination=destination)
forwarding.save()
data_ret = {'status': 1, 'createStatus': 1, 'error_message': "None", 'successMessage': 'Successfully Created!'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'status': 0, 'createStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def fetchEmails(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'listEmails') == 0:
return ACLManager.loadErrorJson('status', 0)
data = json.loads(self.request.body)
selectedDomain = data['selectedDomain']
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(selectedDomain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
try:
emailDomain = Domains.objects.get(domain=selectedDomain)
except:
raise BaseException('No emails exist for this domain.')
records = emailDomain.eusers_set.all()
json_data = "["
checker = 0
for items in records:
dic = {'email': items.email,
}
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)
json_data = json_data + ']'
final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json)
except BaseException, msg:
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
#######
def changeEmailAccountPassword(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'changeEmailPassword') == 0:
return ACLManager.loadError()
if not os.path.exists('/home/cyberpanel/postfix'):
return render(self.request, "mailServer/changeEmailPassword.html", {"status": 0})
websitesName = ACLManager.findAllSites(currentACL, userID)
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
return render(self.request, 'mailServer/changeEmailPassword.html',
{'websiteList': websitesName, "status": 1})
except BaseException, msg:
return HttpResponse(str(msg))
def submitPasswordChange(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'changeEmailPassword') == 0:
return ACLManager.loadErrorJson('passChangeStatus', 0)
data = json.loads(self.request.body)
email = data['email']
password = data['passwordByPass']
emailDB = EUsers.objects.get(email=email)
admin = Administrator.objects.get(pk=userID)
try:
if ACLManager.checkOwnership(emailDB.emailOwner.domainOwner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
except:
if ACLManager.checkOwnership(emailDB.emailOwner.childOwner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
CentOSPath = '/etc/redhat-release'
if os.path.exists(CentOSPath):
password = bcrypt.hashpw(str(password), bcrypt.gensalt())
password = '{CRYPT}%s' % (password)
emailDB.password = password
else:
password = bcrypt.hashpw(str(password), bcrypt.gensalt())
password = '{CRYPT}%s' % (password)
emailDB.password = password
emailDB.save()
data_ret = {'status': 1, 'passChangeStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'status': 0, 'passChangeStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
#######
def dkimManager(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'dkimManager') == 0:
return ACLManager.loadError()
openDKIMInstalled = 1
websitesName = ACLManager.findAllSites(currentACL, userID)
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
return render(self.request, 'mailServer/dkimManager.html',
{'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled})
except BaseException, msg:
return HttpResponse(str(msg))
def fetchDKIMKeys(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'dkimManager') == 0:
return ACLManager.loadErrorJson('fetchStatus', 0)
data = json.loads(self.request.body)
domainName = data['domainName']
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(domainName, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
try:
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
command = "sudo cat " + path
output = ProcessUtilities.outputExecutioner(command, 'opendkim')
leftIndex = output.index('(') + 2
rightIndex = output.rindex(')') - 1
path = "/etc/opendkim/keys/" + domainName + "/default.private"
command = "sudo cat " + path
privateKey = ProcessUtilities.outputExecutioner(command, 'opendkim')
data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 1, 'publicKey': output[leftIndex:rightIndex],
'privateKey': privateKey, 'dkimSuccessMessage': 'Keys successfully fetched!',
'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def generateDKIMKeys(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'dkimManager') == 0:
return ACLManager.loadErrorJson('generateStatus', 0)
data = json.loads(self.request.body)
domainName = data['domainName']
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(domainName, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " generateKeys --domain " + domainName
output = ProcessUtilities.outputExecutioner(execPath)
admin = Administrator.objects.get(pk=userID)
DNS.dnsTemplate(domainName, admin)
if output.find("1,None") > -1:
import tldextract
extractDomain = tldextract.extract(domainName)
topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix
zone = dnsDomains.objects.get(name=topLevelDomain)
zone.save()
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
command = "sudo cat " + path
output = ProcessUtilities.outputExecutioner(command)
leftIndex = output.index('(') + 2
rightIndex = output.rindex(')') - 1
DNS.createDKIMRecords(domainName)
record = dnsRecords(domainOwner=zone,
domain_id=zone.id,
name="default._domainkey." + domainName,
type="TXT",
content=output[leftIndex:rightIndex],
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()
data_ret = {'status': 1, 'generateStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'status': 0, 'generateStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'status': 0, 'generateStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def installOpenDKIM(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'dkimManager') == 0:
return ACLManager.loadErrorJson('installOpenDKIM', 0)
thread.start_new_thread(mailUtilities.installOpenDKIM, ('Install', 'openDKIM'))
final_json = json.dumps({'installOpenDKIM': 1, 'error_message': "None"})
return HttpResponse(final_json)
except BaseException, msg:
final_dic = {'installOpenDKIM': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def installStatusOpenDKIM(self):
try:
command = "sudo cat " + mailUtilities.installLogPath
installStatus = subprocess.check_output(shlex.split(command))
if installStatus.find("[200]") > -1:
execPath = "/usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " configureOpenDKIM"
output = ProcessUtilities.outputExecutioner(execPath)
if output.find("1,None") > -1:
pass
else:
final_json = json.dumps({
'error_message': "Failed to install OpenDKIM configurations.",
'requestStatus': installStatus,
'abort': 1,
'installed': 0,
})
return HttpResponse(final_json)
final_json = json.dumps({
'error_message': "None",
'requestStatus': installStatus,
'abort': 1,
'installed': 1,
})
return HttpResponse(final_json)
elif installStatus.find("[404]") > -1:
final_json = json.dumps({
'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,
})
return HttpResponse(final_json)
except BaseException, msg:
final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)

View File

@@ -7,11 +7,12 @@
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals
from django.db import models
from websiteFunctions.models import Websites
from websiteFunctions.models import Websites, ChildDomains
class Domains(models.Model):
domainOwner = models.ForeignKey(Websites,on_delete=models.CASCADE)
domainOwner = models.ForeignKey(Websites,on_delete=models.CASCADE, null=True)
childOwner = models.ForeignKey(ChildDomains, on_delete=models.CASCADE, null=True)
domain = models.CharField(primary_key=True, max_length=50)
class Meta:
@@ -21,7 +22,9 @@ class Domains(models.Model):
class EUsers(models.Model):
emailOwner = models.ForeignKey(Domains, on_delete=models.CASCADE)
email = models.CharField(primary_key=True, max_length=80)
password = models.CharField(max_length=20)
password = models.CharField(max_length=200)
mail = models.CharField(max_length=200, default='')
class Meta:
db_table = 'e_users'

View File

@@ -0,0 +1,52 @@
from signals import *
from plogical.pluginManagerGlobal import pluginManagerGlobal
class pluginManager:
@staticmethod
def preSubmitEmailCreation(request):
return pluginManagerGlobal.globalPlug(request, preSubmitEmailCreation)
@staticmethod
def postSubmitEmailCreation(request, response):
return pluginManagerGlobal.globalPlug(request, postSubmitEmailCreation, response)
@staticmethod
def preSubmitEmailDeletion(request):
return pluginManagerGlobal.globalPlug(request, preSubmitEmailDeletion)
@staticmethod
def postSubmitEmailDeletion(request, response):
return pluginManagerGlobal.globalPlug(request, postSubmitEmailDeletion, response)
@staticmethod
def preSubmitForwardDeletion(request):
return pluginManagerGlobal.globalPlug(request, preSubmitForwardDeletion)
@staticmethod
def postSubmitForwardDeletion(request, response):
return pluginManagerGlobal.globalPlug(request, postSubmitForwardDeletion, response)
@staticmethod
def preSubmitEmailForwardingCreation(request):
return pluginManagerGlobal.globalPlug(request, preSubmitEmailForwardingCreation)
@staticmethod
def postSubmitEmailForwardingCreation(request, response):
return pluginManagerGlobal.globalPlug(request, postSubmitEmailForwardingCreation, response)
@staticmethod
def preSubmitPasswordChange(request):
return pluginManagerGlobal.globalPlug(request, preSubmitPasswordChange)
@staticmethod
def postSubmitPasswordChange(request, response):
return pluginManagerGlobal.globalPlug(request, postSubmitPasswordChange, response)
@staticmethod
def preGenerateDKIMKeys(request):
return pluginManagerGlobal.globalPlug(request, preGenerateDKIMKeys)
@staticmethod
def postGenerateDKIMKeys(request, response):
return pluginManagerGlobal.globalPlug(request, postGenerateDKIMKeys, response)

40
mailServer/signals.py Normal file
View File

@@ -0,0 +1,40 @@
# The world is a prison for the believer.
## https://www.youtube.com/watch?v=DWfNYztUM1U
from django.dispatch import Signal
## This event is fired before CyberPanel core start creation of an email account.
preSubmitEmailCreation = Signal(providing_args=["request"])
## This event is fired after CyberPanel core finished creation of an email account.
postSubmitEmailCreation = Signal(providing_args=["request", "response"])
## This event is fired before CyberPanel core start deletion of an email account
preSubmitEmailDeletion = Signal(providing_args=["request"])
## This event is fired after CyberPanel core finished deletion of an email account
postSubmitEmailDeletion = Signal(providing_args=["request", "response"])
## This event is fired before CyberPanel core start deletion of email forwarding.
preSubmitForwardDeletion = Signal(providing_args=["request"])
## This event is fired after CyberPanel core finished deletion of email forwarding.
postSubmitForwardDeletion = Signal(providing_args=["request", "response"])
## This event is fired before CyberPanel core start creation of email forwarding.
preSubmitEmailForwardingCreation = Signal(providing_args=["request"])
## This event is fired after CyberPanel core finished creation of email forwarding.
postSubmitEmailForwardingCreation = Signal(providing_args=["request", "response"])
## This event is fired before CyberPanel core start changing password for email account.
preSubmitPasswordChange = Signal(providing_args=["request"])
## This event is fired after CyberPanel core finished changing password for email account.
postSubmitPasswordChange = Signal(providing_args=["request", "response"])
## This event is fired before CyberPanel core start generating dkim keys.
preGenerateDKIMKeys = Signal(providing_args=["request"])
## This event is fired after CyberPanel core finished generating dkim keys.
postGenerateDKIMKeys = Signal(providing_args=["request", "response"])

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

View File

@@ -3,105 +3,138 @@
{% block title %}{% trans "Change Email Password - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Change Email Password" %}</h2>
<p>{% trans "Select a website from the list, to change its password." %}</p>
</div>
<div class="container">
<div id="page-title">
<h2>{% trans "Change Email Password" %}</h2>
<p>{% trans "Select a website from the list, to change its password." %}</p>
</div>
<div ng-controller="changeEmailPassword" class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Change Email Password" %} <img ng-hide="emailLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<div ng-controller="changeEmailPassword" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Change Email Password" %} <img ng-hide="emailLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
{% if not status %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "Postfix is disabled." %}
<a href="{% url 'managePostfix' %}">
<button class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Enable Now" %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
</a></h3>
</div>
<form action="/" class="form-horizontal bordered-row">
{% else %}
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
<div class="col-sm-6">
<select ng-change="showEmailDetails()" ng-model="emailDomain" class="form-control">
{% for items in websiteList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<form action="/" class="form-horizontal bordered-row panel-body">
<!------ Modification form that appears after a click --------------->
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Email" %} </label>
<div class="col-sm-6">
<select ng-model="selectedEmail" class="form-control">
<option ng-repeat="email in emails track by $index">{$ email.email $}</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
<div class="col-sm-6">
<select ng-change="showEmailDetails()" ng-model="emailDomain" class="form-control">
{% for items in websiteList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
<div class="col-sm-6">
<input type="password" class="form-control" ng-model="emailPassword" required>
</div>
</div>
<!------ Modification form that appears after a click --------------->
<!------ Modification form that appears after a click --------------->
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Email" %} </label>
<div class="col-sm-6">
<select ng-model="selectedEmail" class="form-control">
<option ng-repeat="email in emails track by $index">{$ email.email $}</option>
</select>
</div>
</div>
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
<div class="col-sm-6">
<input type="password" class="form-control" ng-model="emailPassword" required>
</div>
<div class="col-sm-3">
<button type="button" ng-click="generatePassword()"
class="btn btn-primary">{% trans "Generate" %}</button>
</div>
</div>
<div ng-hide="generatedPasswordView" class="form-group">
<label class="col-sm-3 control-label">{% trans "Generated Password" %}</label>
<div class="col-sm-6">
<input type="text" name="email" class="form-control" ng-model="emailPassword"
required>
</div>
<div class="col-sm-3">
<button type="button" ng-click="usePassword()"
class="btn btn-primary">{% trans "Use" %}</button>
</div>
</div>
<!------ Modification form that appears after a click --------------->
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="changePassword()"
class="btn btn-primary btn-lg">{% trans "Change Password" %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-6">
<div ng-hide="canNotChangePassword" class="alert alert-danger">
<p>{% trans "Cannot delete email account. Error message:" %} {$ errorMessage
$}</p>
</div>
<div ng-hide="passwordChanged" class="alert alert-success">
<p>{% trans "Password successfully changed for :" %} {$ passEmail $}.</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="noEmails" class="alert alert-danger">
<p>{% trans "Currently no email accounts exist for this domain." %}</p>
</div>
</div>
</div>
</form>
{% endif %}
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="changePassword()" class="btn btn-primary btn-lg btn-block">{% trans "Change Password" %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="canNotChangePassword" class="alert alert-danger">
<p>{% trans "Cannot delete email account. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="passwordChanged" class="alert alert-success">
<p>{% trans "Password successfully changed for :" %} {$ passEmail $}.</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="noEmails" class="alert alert-danger">
<p>{% trans "Currently no email accounts exist for this domain." %}</p>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% endblock %}

View File

@@ -3,100 +3,135 @@
{% block title %}{% trans "Create Email Account - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Create Email Account" %}</h2>
<p>{% trans "Select a website from the list, to create an email account." %}</p>
</div>
<div class="container">
<div id="page-title">
<h2>{% trans "Create Email Account" %}</h2>
<p>{% trans "Select a website from the list, to create an email account." %}</p>
</div>
<div ng-controller="createEmailAccount" class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Create Email Account" %} <img ng-hide="emailLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<div ng-controller="createEmailAccount" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Create Email Account" %} <img ng-hide="emailLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
{% if not status %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "Postfix is disabled." %}
<a href="{% url 'managePostfix' %}">
<button class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Enable Now" %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
</a></h3>
</div>
<form action="/" class="form-horizontal bordered-row">
{% else %}
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
<div class="col-sm-6">
<select ng-change="showEmailDetails()" ng-model="emailDomain" class="form-control">
{% for items in websiteList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<form action="/" class="form-horizontal bordered-row panel-body">
<!------ Modification form that appears after a click --------------->
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
<div class="col-sm-6">
<select ng-change="showEmailDetails()" ng-model="emailDomain" class="form-control">
{% for items in websiteList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "User Name" %}</label>
<div class="col-sm-6">
<input ng-change="hideFewDetails" type="text" class="form-control" ng-model="emailUsername" required>
</div>
<div class="current-pack">@{$ selectedDomain $}</div>
</div>
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
<div class="col-sm-6">
<input type="password" class="form-control" ng-model="emailPassword" required>
</div>
</div>
<!------ Modification form that appears after a click --------------->
<!------ Modification form that appears after a click --------------->
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "User Name" %}</label>
<div class="col-sm-6">
<input ng-change="hideFewDetails" type="text" class="form-control"
ng-model="emailUsername" required>
</div>
<div class="current-pack">@{$ selectedDomain $}</div>
</div>
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
<div class="col-sm-6">
<input type="password" class="form-control" ng-model="emailPassword" required>
</div>
<div class="col-sm-3">
<button type="button" ng-click="generatePassword()"
class="btn btn-primary">{% trans "Generate" %}</button>
</div>
</div>
<div ng-hide="generatedPasswordView" class="form-group">
<label class="col-sm-3 control-label">{% trans "Generated Password" %}</label>
<div class="col-sm-6">
<input type="text" name="email" class="form-control" ng-model="emailPassword"
required>
</div>
<div class="col-sm-3">
<button type="button" ng-click="usePassword()"
class="btn btn-primary">{% trans "Use" %}</button>
</div>
</div>
<!------ Modification form that appears after a click --------------->
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="createEmailAccount()"
class="btn btn-primary btn-lg">{% trans "Create Email" %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-6">
<div ng-hide="canNotCreate" class="alert alert-danger">
<p>{% trans "Cannot create email account. Error message:" %} {$ errorMessage
$}</p>
</div>
<div ng-hide="successfullyCreated" class="alert alert-success">
<p>{% trans "Email with id :" %} {$ createdID
$}{% trans " is successfully created." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
</div>
</form>
{% endif %}
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="createEmailAccount()" class="btn btn-primary btn-lg btn-block">{% trans "Create Email" %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="canNotCreate" class="alert alert-danger">
<p>{% trans "Cannot create email account. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="successfullyCreated" class="alert alert-success">
<p>{% trans "Email with id :" %} {$ createdID $}{% trans " is successfully created." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% endblock %}

View File

@@ -3,104 +3,122 @@
{% block title %}{% trans "Delete Email Account - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Delete Email Account" %}</h2>
<p>{% trans "Select a website from the list, to delete an email account." %}</p>
</div>
<div ng-controller="deleteEmailAccount" class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Delete Email Account" %} <img ng-hide="emailLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
<div class="col-sm-6">
<select ng-change="showEmailDetails()" ng-model="emailDomain" class="form-control">
{% for items in websiteList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<!------ Modification form that appears after a click --------------->
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Email" %} </label>
<div class="col-sm-6">
<select ng-model="selectedEmail" class="form-control">
<option ng-repeat="email in emails track by $index">{$ email.email $}</option>
</select>
</div>
</div>
<!------ Modification form that appears after a click --------------->
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="deleteEmailAccount()" class="btn btn-primary btn-lg btn-block">{% trans "Delete Email" %}</button>
</div>
</div>
<div ng-hide="emailDetailsFinal" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="deleteEmailAccountFinal()" class="btn btn-primary btn-lg btn-block">{% trans "Are you sure?" %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="canNotDelete" class="alert alert-danger">
<p>{% trans "Cannot delete email account. Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="successfullyDeleted" class="alert alert-success">
<p>{% trans "Email with id : {$ deletedID $} is successfully deleted." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="noEmails" class="alert alert-danger">
<p>{% trans "Currently no email accounts exist for this domain." %}</p>
</div>
</div>
</div>
</form>
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Delete Email Account" %}</h2>
<p>{% trans "Select a website from the list, to delete an email account." %}</p>
</div>
<div ng-controller="deleteEmailAccount" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Delete Email Account" %} <img ng-hide="emailLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
{% if not status %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "Postfix is disabled." %}
<a href="{% url 'managePostfix' %}">
<button class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Enable Now" %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
</a></h3>
</div>
{% else %}
<form action="/" class="form-horizontal bordered-row panel-body">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
<div class="col-sm-6">
<select ng-change="showEmailDetails()" ng-model="emailDomain" class="form-control">
{% for items in websiteList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<!------ Modification form that appears after a click --------------->
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Email" %} </label>
<div class="col-sm-6">
<select ng-model="selectedEmail" class="form-control">
<option ng-repeat="email in emails track by $index">{$ email.email $}</option>
</select>
</div>
</div>
<!------ Modification form that appears after a click --------------->
<div ng-hide="emailDetails" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="deleteEmailAccount()"
class="btn btn-primary btn-lg">{% trans "Delete Email" %}</button>
</div>
</div>
<div ng-hide="emailDetailsFinal" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="deleteEmailAccountFinal()"
class="btn btn-primary btn-lg">{% trans "Are you sure?" %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-6">
<div ng-hide="canNotDelete" class="alert alert-danger">
<p>{% trans "Cannot delete email account. Error message:" %} {$ errorMessage
$}</p>
</div>
<div ng-hide="successfullyDeleted" class="alert alert-success">
<p>{% trans "Email with id : {$ deletedID $} is successfully deleted." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
<div ng-hide="noEmails" class="alert alert-danger">
<p>{% trans "Currently no email accounts exist for this domain." %}</p>
</div>
</div>
</div>
</form>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% endblock %}

View File

@@ -18,11 +18,11 @@
{% if openDKIMInstalled == 0 %}
<div class="panel-body">
<h3 class="title-hero">
<h3 class="content-box-header">
{% trans "DKIM Manager" %} <img ng-hide="manageDKIMLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">
<form action="/" class="form-horizontal bordered-row panel-body">
<div class="form-group text-center">
<h3>{% trans "OpenDKIM is not installed. " %}
<a href="" ng-click="installOpenDKIM()"><strong>{% trans "Install Now" %}</strong></a>
@@ -53,7 +53,7 @@
<div ng-hide="openDKIMInstallBox" class="col-md-12">
<form action="/" id="" class="form-horizontal bordered-row">
<form action="/" id="" class="form-horizontal bordered-row panel-body">
<div class="form-group">
<div style="margin-top: 2%;" class="col-sm-12">
<textarea ng-model="requestData" rows="15" class="form-control">{{ requestData }}</textarea>
@@ -71,12 +71,12 @@
</div>
{% else %}
<div class="panel-body">
<h3 class="title-hero">
<h3 class="content-box-header">
{% trans "DKIM Manager" %} <img ng-hide="manageDKIMLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">
<form action="/" class="form-horizontal bordered-row panel-body">
<div class="form-group">
@@ -173,4 +173,4 @@
</div>
{% endblock %}
{% endblock %}

View File

@@ -15,14 +15,24 @@
<div ng-controller="emailForwarding" class="panel">
<div class="panel-body">
<h3 class="title-hero">
<h3 class="content-box-header">
{% trans "Setup Email Forwarding" %} <img ng-hide="forwardLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
{% if not status %}
<form action="/" class="form-horizontal bordered-row">
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "Postfix is disabled." %}
<a href="{% url 'managePostfix' %}"><button class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Enable Now" %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button></a></h3>
</div>
{% else %}
<form action="/" class="form-horizontal bordered-row panel-body">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
@@ -105,7 +115,7 @@
<td ng-bind="record.id"></td>
<td ng-bind="record.source"></td>
<td ng-bind="record.destination"></td>
<td ng-click="deleteForwarding(record.destination)"><img src="{% static 'images/delete.png' %}"></td>
<td ng-click="deleteForwarding(record.source, record.destination)"><img src="{% static 'images/delete.png' %}"></td>
</tr>
</tbody>
</table>
@@ -118,6 +128,8 @@
</form>
{% endif %}
@@ -129,4 +141,4 @@
</div>
{% endblock %}
{% endblock %}

View File

@@ -3,68 +3,71 @@
{% block title %}{% trans "Mail Functions - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "Mail Functions" %}</h2>
<p>{% trans "Manage email accounts on this page." %}</p>
</div>
<div class="container">
<div id="page-title">
<h2>{% trans "Mail Functions" %}</h2>
<p>{% trans "Manage email accounts on this page." %}</p>
</div>
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Available Functions" %}
</h3>
<div class="panel col-md-12">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Available Functions" %}
</h3>
<div class="example-box-wrapper">
<div class="row">
<div class="col-md-4">
<a href="{% url 'createEmailAccount' %}" title="{% trans 'Create Email' %}" class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
{% trans "Create Email" %}
</div>
<div class="tile-content-wrapper">
<i class="glyph-icon icon-dashboard"></i>
</div>
</a>
</div>
<div class="example-box-wrapper">
<div class="row">
<div class="col-md-3 btn-min-width">
<a href="{% url 'createEmailAccount' %}" title="{% trans 'Create Email' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
{% trans "Create Email" %}
</div>
<div class="tile-content-wrapper">
<i class="fa fa-plus-square"></i>
</div>
</a>
</div>
<div class="col-md-4">
<a href="{% url 'deleteEmailAccount' %}" title="{% trans 'Delete Email' %}" class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
{% trans "Delete Email" %}
</div>
<div class="tile-content-wrapper">
<i class="glyph-icon icon-dashboard"></i>
</div>
</a>
</div>
<div class="col-md-3 btn-min-width">
<a href="{% url 'deleteEmailAccount' %}" title="{% trans 'Delete Email' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
{% trans "Delete Email" %}
</div>
<div class="tile-content-wrapper">
<i class="fa fa-trash"></i>
</div>
</a>
</div>
<div class="col-md-3 btn-min-width">
<a href="{% url 'changeEmailAccountPassword' %}" title="{% trans 'Change Password' %}"
class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
{% trans "Change Password" %}
</div>
<div class="tile-content-wrapper">
<i class="fa fa-key"></i>
</div>
</a>
</div>
<div class="col-md-4">
<a href="{% url 'changeEmailAccountPassword' %}" title="{% trans 'Change Password' %}" class="tile-box tile-box-shortcut btn-primary">
<div class="tile-header">
{% trans "Change Password" %}
</div>
<div class="tile-content-wrapper">
<i class="glyph-icon icon-dashboard"></i>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% endblock %}

View File

@@ -0,0 +1,164 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "List Email Accounts - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "List Email Accounts" %}</h2>
<p>{% trans "List Emails Accounts. Change their passwords or delete them." %}</p>
</div>
<div ng-controller="listEmails" class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "List Email Accounts" %} <img ng-hide="cyberpanelLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
{% if not status %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "Postfix is disabled." %}
<a href="{% url 'managePostfix' %}">
<button class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Enable Now" %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
</a></h3>
</div>
{% else %}
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Domain" %}</label>
<div class="col-sm-6">
<select ng-change="populateCurrentRecords()" ng-model="selectedDomain"
class="form-control">
{% for items in websiteList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<!------ List of records --------------->
<div ng-hide="emailsAccounts" class="form-group">
<div class="col-sm-12">
<table class="table">
<thead>
<tr>
<th>{% trans "Emails" %}</th>
<th>{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="record in records track by $index">
<td ng-bind="record.email"></td>
<td>
<a data-toggle="modal" data-target="#settings"
ng-click="changePasswordInitial(record.email)"
class="btn btn-border btn-alt border-purple btn-link font-purple"
href="#"
title=""><span>{% trans 'Change Password' %}</span></a>
<a ng-click="deleteEmailAccountFinal(record.email)" class="btn btn-border btn-alt border-red btn-link font-red" href="#"
title=""><span>{% trans 'Delete' %}</span></a>
<!--- Modal --->
<div id="settings" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal">&times;
</button>
<h4 class="modal-title">Change Password
<img ng-hide="cyberpanelLoading"
src="{% static 'images/loading.gif' %}">
</h4>
</div>
<div class="modal-body">
<form name="containerSettingsForm" action="/"
class="form-horizontal">
<div ng-hide="installationDetailsForm"
class="form-group">
<label class="col-sm-3 control-label">{% trans "Email" %}</label>
<div class="col-sm-6">
<input name="name" type="text"
class="form-control"
ng-model="email" readonly>
</div>
</div>
<hr>
<div ng-hide="installationDetailsForm"
class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
<div class="col-sm-6">
<input type="password"
class="form-control"
ng-model="$parent.password">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" ng-disabled="savingSettings"
class="btn btn-primary"
ng-click="changePassword()"
data-dismiss="modal">
Save
</button>
<button type="button" ng-disabled="savingSettings"
class="btn btn-default" data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
<!--- Modal End--->
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!------ List of records --------------->
</form>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -4,7 +4,9 @@ import views
urlpatterns = [
url(r'^$', views.loadEmailHome, name='loadEmailHome'),
url(r'^createEmailAccount', views.createEmailAccount, name='createEmailAccount'),
url(r'^listEmails$', views.listEmails, name='listEmails'),
url(r'^submitEmailCreation', views.submitEmailCreation, name='submitEmailCreation'),
url(r'^fetchEmails$', views.fetchEmails, name='fetchEmails'),
## Mail Forwardings

View File

@@ -1,175 +1,71 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render,redirect
from django.shortcuts import redirect
from django.http import HttpResponse
from models import Domains,EUsers
# Create your views here.
from loginSystem.models import Administrator
from websiteFunctions.models import Websites
from loginSystem.views import loadLoginPage
import plogical.CyberCPLogFileWriter as logging
import json
import shlex
import subprocess
from plogical.virtualHostUtilities import virtualHostUtilities
from plogical.mailUtilities import mailUtilities
import thread
from dns.models import Domains as dnsDomains
from dns.models import Records as dnsRecords
from mailServer.models import Forwardings
from mailserverManager import MailServerManager
from pluginManager import pluginManager
def loadEmailHome(request):
try:
val = request.session['userID']
return render(request, 'mailServer/index.html')
msM = MailServerManager(request)
return msM.loadEmailHome()
except KeyError:
return redirect(loadLoginPage)
def createEmailAccount(request):
try:
val = request.session['userID']
try:
admin = Administrator.objects.get(pk=val)
if admin.type == 1:
websites = Websites.objects.all()
else:
websites = Websites.objects.filter(admin=admin)
websitesName = []
for items in websites:
websitesName.append(items.domain)
return render(request, 'mailServer/createEmailAccount.html', {'websiteList':websitesName})
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return HttpResponse(str(msg))
msM = MailServerManager(request)
return msM.createEmailAccount()
except KeyError:
return redirect(loadLoginPage)
def listEmails(request):
try:
msM = MailServerManager(request)
return msM.listEmails()
except KeyError:
return redirect(loadLoginPage)
def fetchEmails(request):
try:
msM = MailServerManager(request)
return msM.fetchEmails()
except KeyError:
return redirect(loadLoginPage)
def submitEmailCreation(request):
try:
if request.method == 'POST':
val = request.session['userID']
result = pluginManager.preSubmitEmailCreation(request)
if result != 200:
return result
data = json.loads(request.body)
domainName = data['domain']
userName = data['username']
password = data['password']
msM = MailServerManager(request)
coreResult = msM.submitEmailCreation()
## Create email entry
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " createEmailAccount --domain " + domainName + " --userName " \
+ userName + " --password " + password
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'createEmailStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'createEmailStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
## create email entry ends
except BaseException, msg:
data_ret = {'createEmailStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def deleteEmailAccount(request):
try:
val = request.session['userID']
try:
admin = Administrator.objects.get(pk=val)
if admin.type == 1:
websites = Websites.objects.all()
else:
websites = Websites.objects.filter(admin=admin)
websitesName = []
for items in websites:
websitesName.append(items.domain)
return render(request, 'mailServer/deleteEmailAccount.html', {'websiteList':websitesName})
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return HttpResponse(str(msg))
result = pluginManager.postSubmitEmailCreation(request, coreResult)
if result != 200:
return result
return coreResult
except KeyError:
return redirect(loadLoginPage)
def deleteEmailAccount(request):
try:
msM = MailServerManager(request)
return msM.deleteEmailAccount()
except KeyError:
return redirect(loadLoginPage)
def getEmailsForDomain(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if request.method == 'POST':
data = json.loads(request.body)
domain = data['domain']
try:
domain = Domains.objects.get(domain=domain)
except:
final_dic = {'fetchStatus': 0, 'error_message': "No email accounts exists!"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
if admin.type != 1:
if domain.domainOwner.admin != admin:
final_dic = {'fetchStatus': 0, 'error_message': "Not enough privileges." }
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
emails = domain.eusers_set.all()
if emails.count() == 0:
final_dic = {'fetchStatus': 0, 'error_message': "No email accounts exists!"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
json_data = "["
checker = 0
for items in emails:
dic = {'email': items.email}
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)
json_data = json_data + ']'
final_dic = {'fetchStatus': 1, 'error_message': "None", "data": json_data}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException,msg:
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
msM = MailServerManager(request)
return msM.getEmailsForDomain()
except KeyError,msg:
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
@@ -177,30 +73,19 @@ def getEmailsForDomain(request):
def submitEmailDeletion(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if request.method == 'POST':
data = json.loads(request.body)
email = data['email']
emailDB = EUsers.objects.get(email=email)
result = pluginManager.preSubmitEmailDeletion(request)
if result != 200:
return result
if admin.type != 1:
if emailDB.emailOwner.domainOwner.admin != admin:
final_dic = {'deleteEmailStatus': 0, 'error_message': "Not enough privileges."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
msM = MailServerManager(request)
coreResult = msM.submitEmailDeletion()
mailUtilities.deleteEmailAccount(email)
data_ret = {'deleteEmailStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
result = pluginManager.postSubmitEmailDeletion(request, coreResult)
if result != 200:
return result
except BaseException,msg:
data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
return coreResult
except KeyError,msg:
data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
@@ -208,76 +93,15 @@ def submitEmailDeletion(request):
def emailForwarding(request):
try:
val = request.session['userID']
try:
admin = Administrator.objects.get(pk=val)
if admin.type == 1:
websites = Websites.objects.all()
else:
websites = Websites.objects.filter(admin=admin)
websitesName = []
for items in websites:
websitesName.append(items.domain)
return render(request, 'mailServer/emailForwarding.html', {'websiteList':websitesName})
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return HttpResponse(str(msg))
msM = MailServerManager(request)
return msM.emailForwarding()
except KeyError:
return redirect(loadLoginPage)
def fetchCurrentForwardings(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if request.method == 'POST':
data = json.loads(request.body)
emailAddress = data['emailAddress']
emailDB = EUsers.objects.get(email=emailAddress)
if admin.type != 1:
if emailDB.emailOwner.domainOwner.admin != admin:
final_dic = {'fetchStatus': 1, 'error_message': "Not enough privileges."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
currentForwardings = Forwardings.objects.filter(source=emailAddress)
json_data = "["
checker = 0
id = 1
for items in currentForwardings:
if items.source == items.destination:
continue
dic = {'id': id,
'source': items.source,
'destination': items.destination}
id = id + 1
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)
json_data = json_data + ']'
final_dic = {'fetchStatus': 1, 'error_message': "None", "data": json_data}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException,msg:
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
msM = MailServerManager(request)
return msM.fetchCurrentForwardings()
except KeyError,msg:
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
@@ -285,24 +109,19 @@ def fetchCurrentForwardings(request):
def submitForwardDeletion(request):
try:
val = request.session['userID']
try:
if request.method == 'POST':
data = json.loads(request.body)
destination = data['destination']
result = pluginManager.preSubmitForwardDeletion(request)
if result != 200:
return result
forwarding = Forwardings.objects.get(destination=destination)
forwarding.delete()
msM = MailServerManager(request)
coreResult = msM.submitForwardDeletion()
data_ret = {'deleteForwardingStatus': 1, 'error_message': "None", 'successMessage':'Successfully deleted!'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
result = pluginManager.postSubmitForwardDeletion(request, coreResult)
if result != 200:
return result
except BaseException,msg:
data_ret = {'deleteForwardingStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
return coreResult
except KeyError,msg:
data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
@@ -310,116 +129,48 @@ def submitForwardDeletion(request):
def submitEmailForwardingCreation(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if request.method == 'POST':
result = pluginManager.preSubmitEmailForwardingCreation(request)
if result != 200:
return result
data = json.loads(request.body)
source = data['source']
destination = data['destination']
msM = MailServerManager(request)
coreResult = msM.submitEmailForwardingCreation()
email = EUsers.objects.get(email=source)
result = pluginManager.postSubmitEmailForwardingCreation(request, coreResult)
if result != 200:
return result
if admin.type != 1:
if email.emailOwner.domainOwner.admin != admin:
final_dic = {'createStatus': 0, 'error_message': "Not enough privileges." }
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
if Forwardings.objects.filter(source=source, destination=destination).count() > 0:
data_ret = {'createStatus': 0, 'error_message': "You have already forwared to this destination."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
if Forwardings.objects.filter(source=source).count() == 0:
forwarding = Forwardings(source=source, destination=source)
forwarding.save()
forwarding = Forwardings(source=source, destination=destination)
forwarding.save()
data_ret = {'createStatus': 1, 'error_message': "None", 'successMessage':'Successfully Created!'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
data_ret = {'createStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
return coreResult
except KeyError,msg:
data_ret = {'createStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
#######
def changeEmailAccountPassword(request):
try:
val = request.session['userID']
try:
admin = Administrator.objects.get(pk=request.session['userID'])
if admin.type == 1:
websites = Websites.objects.all()
else:
websites = Websites.objects.filter(admin=admin)
websitesName = []
for items in websites:
websitesName.append(items.domain)
return render(request, 'mailServer/changeEmailPassword.html', {'websiteList':websitesName})
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return HttpResponse(str(msg))
msM = MailServerManager(request)
return msM.changeEmailAccountPassword()
except KeyError:
return redirect(loadLoginPage)
def submitPasswordChange(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if request.method == 'POST':
data = json.loads(request.body)
domain = data['domain']
email = data['email']
password = data['password']
result = pluginManager.preSubmitPasswordChange(request)
if result != 200:
return result
emailDB = EUsers.objects.get(email=email)
msM = MailServerManager(request)
coreResult = msM.submitPasswordChange()
if admin.type != 1:
if emailDB.emailOwner.domainOwner.admin != admin:
final_dic = {'passChangeStatus': 0, 'error_message': "Not enough privileges." }
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
result = pluginManager.postSubmitPasswordChange(request, coreResult)
if result != 200:
return result
emailDB.delete()
dom = Domains(domain=domain)
emailAcct = EUsers(emailOwner=dom, email=email, password=password)
emailAcct.save()
data_ret = {'passChangeStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
data_ret = {'passChangeStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
return coreResult
except KeyError,msg:
data_ret = {'passChangeStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
@@ -429,97 +180,15 @@ def submitPasswordChange(request):
def dkimManager(request):
try:
val = request.session['userID']
openDKIMInstalled = 0
if mailUtilities.checkIfDKIMInstalled() == 1:
openDKIMInstalled = 1
admin = Administrator.objects.get(pk=val)
if admin.type == 1:
websites = Websites.objects.all()
websitesName = []
for items in websites:
websitesName.append(items.domain)
else:
if admin.type == 2:
websites = admin.websites_set.all()
admins = Administrator.objects.filter(owner=admin.pk)
websitesName = []
for items in websites:
websitesName.append(items.domain)
for items in admins:
webs = items.websites_set.all()
for web in webs:
websitesName.append(web.domain)
else:
websitesName = []
websites = Websites.objects.filter(admin=admin)
for items in websites:
websitesName.append(items.domain)
return render(request, 'mailServer/dkimManager.html',
{'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled})
return render(request, 'mailServer/dkimManager.html',
{'openDKIMInstalled': openDKIMInstalled})
msM = MailServerManager(request)
return msM.dkimManager()
except KeyError:
return redirect(loadLoginPage)
def fetchDKIMKeys(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if request.method == 'POST':
data = json.loads(request.body)
domainName = data['domainName']
if admin.type != 1:
website = Websites.objects.get(domain=domainName)
if website.admin != admin:
data_ret = {'fetchStatus': 0, 'keysAvailable': 0, 'error_message': 'Not enough privileges.'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
try:
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
command = "sudo cat " + path
output = subprocess.check_output(shlex.split(command))
path = "/etc/opendkim/keys/" + domainName + "/default.private"
command = "sudo cat " + path
privateKey = subprocess.check_output(shlex.split(command))
data_ret = {'fetchStatus': 1, 'keysAvailable': 1, 'publicKey': output[53:269],
'privateKey': privateKey, 'dkimSuccessMessage': 'Keys successfully fetched!', 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
data_ret = {'fetchStatus': 1, 'keysAvailable': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
msM = MailServerManager(request)
return msM.fetchDKIMKeys()
except KeyError,msg:
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
@@ -527,58 +196,19 @@ def fetchDKIMKeys(request):
def generateDKIMKeys(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if request.method == 'POST':
data = json.loads(request.body)
domainName = data['domainName']
result = pluginManager.preGenerateDKIMKeys(request)
if result != 200:
return result
if admin.type != 1:
website = Websites.objects.get(domain=domainName)
if website.admin != admin:
data_ret = {'generateStatus': 0, 'error_message': 'Not enough privileges.'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
msM = MailServerManager(request)
coreResult = msM.generateDKIMKeys()
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " generateKeys --domain " + domainName
output = subprocess.check_output(shlex.split(execPath))
result = pluginManager.postGenerateDKIMKeys(request, coreResult)
if result != 200:
return result
if output.find("1,None") > -1:
zone = dnsDomains.objects.get(name=domainName)
zone.save()
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
command = "sudo cat " + path
output = subprocess.check_output(shlex.split(command))
record = dnsRecords(domainOwner=zone,
domain_id=zone.id,
name="default._domainkey." + domainName,
type="TXT",
content="v=DKIM1; k=rsa; p=" + output[53:269],
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()
data_ret = {'generateStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'generateStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
data_ret = {'generateStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
return coreResult
except BaseException, msg:
data_ret = {'generateStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
@@ -586,20 +216,8 @@ def generateDKIMKeys(request):
def installOpenDKIM(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if admin.type != 1:
final_json = json.dumps({'installOpenDKIM': 0, 'error_message': "Not enough privileges."})
return HttpResponse(final_json)
thread.start_new_thread(mailUtilities.installOpenDKIM, ('Install','openDKIM'))
final_json = json.dumps({'installOpenDKIM': 1, 'error_message': "None"})
return HttpResponse(final_json)
except BaseException,msg:
final_dic = {'installOpenDKIM': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
msM = MailServerManager(request)
return msM.installOpenDKIM()
except KeyError:
final_dic = {'installOpenDKIM': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
@@ -607,68 +225,8 @@ def installOpenDKIM(request):
def installStatusOpenDKIM(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if request.method == 'POST':
if admin.type != 1:
final_dic = {'abort': 1, 'installed': 0, 'error_message': 'Not enough privileges.'}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
command = "sudo cat " + mailUtilities.installLogPath
installStatus = subprocess.check_output(shlex.split(command))
if installStatus.find("[200]")>-1:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " configureOpenDKIM"
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
pass
else:
final_json = json.dumps({
'error_message': "Failed to install OpenDKIM configurations.",
'requestStatus': installStatus,
'abort': 1,
'installed': 0,
})
return HttpResponse(final_json)
final_json = json.dumps({
'error_message': "None",
'requestStatus': installStatus,
'abort':1,
'installed': 1,
})
return HttpResponse(final_json)
elif installStatus.find("[404]") > -1:
final_json = json.dumps({
'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,
})
return HttpResponse(final_json)
except BaseException,msg:
final_dic = {'abort':1,'installed':0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
msM = MailServerManager()
return msM.installStatusOpenDKIM()
except KeyError:
final_dic = {'abort':1,'installed':0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)