diff --git a/CyberCP/__init__.pyc b/CyberCP/__init__.pyc
index b4c1a3d74..64abb8684 100644
Binary files a/CyberCP/__init__.pyc and b/CyberCP/__init__.pyc differ
diff --git a/CyberCP/settings.py b/CyberCP/settings.py
index 22991f473..88ef6d3fd 100644
--- a/CyberCP/settings.py
+++ b/CyberCP/settings.py
@@ -58,6 +58,7 @@ INSTALLED_APPS = [
'manageSSL',
'api',
'filemanager',
+ 'emailPremium'
]
MIDDLEWARE = [
diff --git a/CyberCP/settings.pyc b/CyberCP/settings.pyc
index 2462b2a46..bd8226e4a 100644
Binary files a/CyberCP/settings.pyc and b/CyberCP/settings.pyc differ
diff --git a/CyberCP/urls.py b/CyberCP/urls.py
index 748d094b7..f69178e01 100644
--- a/CyberCP/urls.py
+++ b/CyberCP/urls.py
@@ -35,4 +35,5 @@ urlpatterns = [
url(r'^manageSSL/',include('manageSSL.urls')),
url(r'^api/',include('api.urls')),
url(r'^filemanager/',include('filemanager.urls')),
+ url(r'^emailPremium/',include('emailPremium.urls')),
]
diff --git a/api/__init__.pyc b/api/__init__.pyc
index b65fd3706..cafcf5aa5 100644
Binary files a/api/__init__.pyc and b/api/__init__.pyc differ
diff --git a/api/admin.pyc b/api/admin.pyc
index 82f1d16fa..74a54ef27 100644
Binary files a/api/admin.pyc and b/api/admin.pyc differ
diff --git a/api/models.pyc b/api/models.pyc
index 3561deb50..eb8824f35 100644
Binary files a/api/models.pyc and b/api/models.pyc differ
diff --git a/backup/__init__.pyc b/backup/__init__.pyc
index a070efdd6..f315985d0 100644
Binary files a/backup/__init__.pyc and b/backup/__init__.pyc differ
diff --git a/backup/admin.pyc b/backup/admin.pyc
index 18caa545d..4d2523c91 100644
Binary files a/backup/admin.pyc and b/backup/admin.pyc differ
diff --git a/backup/models.pyc b/backup/models.pyc
index 4b928877f..93c542b78 100644
Binary files a/backup/models.pyc and b/backup/models.pyc differ
diff --git a/baseTemplate/__init__.pyc b/baseTemplate/__init__.pyc
index 25e5b7d66..c01a8aaad 100644
Binary files a/baseTemplate/__init__.pyc and b/baseTemplate/__init__.pyc differ
diff --git a/baseTemplate/admin.pyc b/baseTemplate/admin.pyc
index cb9c918b2..c40f5d03d 100644
Binary files a/baseTemplate/admin.pyc and b/baseTemplate/admin.pyc differ
diff --git a/baseTemplate/models.pyc b/baseTemplate/models.pyc
index 0b1265b82..0833bba84 100644
Binary files a/baseTemplate/models.pyc and b/baseTemplate/models.pyc differ
diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html
index 96393f6a7..057203e17 100755
--- a/baseTemplate/templates/baseTemplate/index.html
+++ b/baseTemplate/templates/baseTemplate/index.html
@@ -464,7 +464,6 @@
{% trans "Tuning" %}
- {% trans "NEW" %}
+
+
+
+ {% trans "Mail Settings" %}
+ {% trans "NEW" %}
+
+
+
+
@@ -586,6 +600,7 @@
+
diff --git a/databases/__init__.pyc b/databases/__init__.pyc
index f8e7593fc..20b7d6602 100644
Binary files a/databases/__init__.pyc and b/databases/__init__.pyc differ
diff --git a/databases/admin.pyc b/databases/admin.pyc
index b3edea730..8c25f8f36 100644
Binary files a/databases/admin.pyc and b/databases/admin.pyc differ
diff --git a/databases/models.pyc b/databases/models.pyc
index 479ad2eee..ba555fcd2 100644
Binary files a/databases/models.pyc and b/databases/models.pyc differ
diff --git a/dns/__init__.pyc b/dns/__init__.pyc
index e13d9790c..76ee38f94 100644
Binary files a/dns/__init__.pyc and b/dns/__init__.pyc differ
diff --git a/dns/admin.pyc b/dns/admin.pyc
index 590876449..9fdc2ee11 100644
Binary files a/dns/admin.pyc and b/dns/admin.pyc differ
diff --git a/dns/models.pyc b/dns/models.pyc
index 0c689a527..12a616347 100644
Binary files a/dns/models.pyc and b/dns/models.pyc differ
diff --git a/emailPremium/__init__.py b/emailPremium/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/emailPremium/__init__.pyc b/emailPremium/__init__.pyc
new file mode 100644
index 000000000..d77c0fe14
Binary files /dev/null and b/emailPremium/__init__.pyc differ
diff --git a/emailPremium/admin.py b/emailPremium/admin.py
new file mode 100644
index 000000000..13be29d96
--- /dev/null
+++ b/emailPremium/admin.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.contrib import admin
+
+# Register your models here.
diff --git a/emailPremium/admin.pyc b/emailPremium/admin.pyc
new file mode 100644
index 000000000..067b5361a
Binary files /dev/null and b/emailPremium/admin.pyc differ
diff --git a/emailPremium/apps.py b/emailPremium/apps.py
new file mode 100644
index 000000000..69075763f
--- /dev/null
+++ b/emailPremium/apps.py
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class EmailpremiumConfig(AppConfig):
+ name = 'emailPremium'
diff --git a/emailPremium/migrations/__init__.py b/emailPremium/migrations/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/emailPremium/models.py b/emailPremium/models.py
new file mode 100644
index 000000000..b40864678
--- /dev/null
+++ b/emailPremium/models.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models
+from mailServer.models import Domains, EUsers
+# Create your models here.
+
+
+
+class DomainLimits(models.Model):
+ domain = models.ForeignKey(Domains, on_delete=models.CASCADE)
+ limitStatus = models.IntegerField(default=0)
+ monthlyLimit = models.IntegerField(default=10000)
+ monthlyUsed = models.IntegerField(default=0)
+
+class EmailLimits(models.Model):
+ email = models.ForeignKey(EUsers, on_delete=models.CASCADE)
+ limitStatus = models.IntegerField(default=0)
+ monthlyLimits = models.IntegerField(default=2000)
+ monthlyUsed = models.IntegerField(default=0)
+ hourlyLimit = models.IntegerField(default=50)
+ hourlyUsed = models.IntegerField(default=0)
+ emailLogs = models.IntegerField(default=0)
+
+class EmailLogs(models.Model):
+ email = models.ForeignKey(EUsers, on_delete=models.CASCADE)
+ destination = models.CharField(max_length=200)
+ timeStamp = models.CharField(max_length=200)
+
diff --git a/emailPremium/models.pyc b/emailPremium/models.pyc
new file mode 100644
index 000000000..575d46341
Binary files /dev/null and b/emailPremium/models.pyc differ
diff --git a/emailPremium/static/emailPremium/emailPremium.js b/emailPremium/static/emailPremium/emailPremium.js
new file mode 100644
index 000000000..356fb1fca
--- /dev/null
+++ b/emailPremium/static/emailPremium/emailPremium.js
@@ -0,0 +1,673 @@
+/**
+ * Created by usman on 6/22/18.
+ */
+
+/* Java script code to list accounts */
+
+app.controller('listDomains', function($scope,$http) {
+
+ $scope.listFail = true;
+ $scope.emailLimitsLoading = true;
+
+ // Global page number, to be used in later function to refresh the domains
+ var globalPageNumber;
+
+
+ $scope.getFurtherWebsitesFromDB = function(pageNumber) {
+
+ globalPageNumber = pageNumber;
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/getFurtherDomains";
+
+ var data = {page: pageNumber};
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.listWebSiteStatus === 1) {
+
+ $scope.WebSitesList = JSON.parse(response.data.data);
+ $scope.listFail = true;
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+ $scope.getFurtherWebsitesFromDB(1);
+
+ $scope.enableDisableEmailLimits = function (operationVal, domainName) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ domainName: domainName
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $scope.getFurtherWebsitesFromDB(globalPageNumber);
+ $scope.listFail = true;
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+ }
+});
+
+/* Java script code to list accounts ends here */
+
+
+
+/* Java script code for email domain page */
+
+app.controller('emailDomainPage', function($scope,$http, $timeout, $window) {
+
+ $scope.listFail = true;
+ $scope.emailLimitsLoading = true;
+
+ var globalDomainName = window.location.pathname.split("/")[2];
+
+ // Global page number, to be used in later function to refresh the domains
+ var globalPageNumber;
+
+
+ $scope.getFurtherEmailsFromDB = function(pageNumber) {
+
+ globalPageNumber = pageNumber;
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/getFurtherEmail";
+
+ var data = {
+ page: pageNumber,
+ domainName: globalDomainName
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $scope.emailList = JSON.parse(response.data.data);
+ $scope.listFail = true;
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+ $scope.getFurtherEmailsFromDB(1);
+
+ $scope.enableDisableEmailLimits = function (operationVal, domainName) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ domainName: domainName
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $timeout(function() { $window.location.reload(); }, 0);
+ }
+ else
+ {
+ $timeout(function() { $window.location.reload(); }, 0);
+ }
+ }
+ function cantLoadInitialData(response) {
+ $timeout(function() { $window.location.reload(); }, 0);
+ }
+ };
+
+
+ /// Email limits
+
+ $scope.changeLimitsForm = true;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+
+ $scope.showLimitsForm = function () {
+ $scope.changeLimitsForm = false;
+ };
+
+ $scope.hideLimitsForm = function () {
+ $scope.changeLimitsForm = true;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+ };
+
+ $scope.changeDomainEmailLimits = function (domainName) {
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/changeDomainLimit";
+
+ var data = {
+ domainName: domainName,
+ newLimit: $scope.monthlyLimit
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+
+ if (response.data.status === 1) {
+
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = false;
+ $scope.couldNotConnect = true;
+ $timeout(function() { $window.location.reload(); }, 3000);
+ }
+ else
+ {
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = false;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = false;
+ }
+ }
+
+
+ $scope.enableDisableIndividualEmailLimits = function (operationVal, emailAddress) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableIndividualEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ emailAddress: emailAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+ $scope.getFurtherEmailsFromDB(1);
+ }
+ else
+ {
+ $scope.getFurtherEmailsFromDB(1);
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.getFurtherEmailsFromDB(1);
+ }
+ };
+
+});
+
+/* Java script code for email domain page */
+
+
+/* Java script code for Email Page */
+
+app.controller('emailPage', function($scope,$http, $timeout, $window) {
+
+ $scope.emailLimitsLoading = true;
+
+ var globalEamilAddress = $("#emailAddress").text();
+
+ // Global page number, to be used in later function to refresh the domains
+ var globalPageNumber;
+
+ $scope.getEmailStats = function() {
+
+ $scope.emailLimitsLoading = false;
+
+ ////
+
+ $scope.limitsOn = true;
+ $scope.limitsOff = true;
+
+ url = "/emailPremium/getEmailStats";
+
+ var data = {
+ emailAddress: globalEamilAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $scope.monthlyLimit = response.data.monthlyLimit;
+ $scope.monthlyUsed = response.data.monthlyUsed;
+ $scope.hourlyLimit = response.data.hourlyLimit;
+ $scope.hourlyUsed = response.data.hourlyUsed;
+
+ if(response.data.limitStatus === 1){
+ $scope.limitsOn = false;
+ $scope.limitsOff = true;
+ }else{
+ $scope.limitsOn = true;
+ $scope.limitsOff = false;
+ }
+
+ if(response.data.logsStatus === 1){
+ $scope.loggingOn = false;
+ $scope.loggingOff = true;
+ }else{
+ $scope.loggingOn = true;
+ $scope.loggingOff = false;
+ }
+
+ }
+ else
+ {
+
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+ $scope.getEmailStats();
+
+ $scope.enableDisableIndividualEmailLimits = function (operationVal, emailAddress) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableIndividualEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ emailAddress: emailAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+ $scope.getEmailStats();
+ }
+ else
+ {
+ $scope.getEmailStats();
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.getEmailStats();
+ }
+ };
+ $scope.enableDisableIndividualEmailLogs = function (operationVal, emailAddress) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableIndividualEmailLogs";
+
+ var data = {
+ operationVal: operationVal,
+ emailAddress: emailAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+ $scope.getEmailStats();
+ }
+ else
+ {
+ $scope.getEmailStats();
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.getEmailStats();
+ }
+ };
+
+
+ $scope.enableDisableEmailLimits = function (operationVal, domainName) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ domainName: domainName
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $timeout(function() { $window.location.reload(); }, 0);
+ }
+ else
+ {
+ $timeout(function() { $window.location.reload(); }, 0);
+ }
+ }
+ function cantLoadInitialData(response) {
+ $timeout(function() { $window.location.reload(); }, 0);
+ }
+ };
+
+
+ /// Email limits
+ $scope.changeLimitsForm = true;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+
+ $scope.showLimitsForm = function () {
+ $scope.changeLimitsForm = false;
+ };
+
+ $scope.hideLimitsForm = function () {
+ $scope.changeLimitsForm = true;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+ };
+
+ $scope.changeDomainEmailLimitsIndividual = function () {
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/changeDomainEmailLimitsIndividual";
+
+ var data = {
+ emailAddress: globalEamilAddress,
+ monthlyLimit: $scope.monthlyLimitForm,
+ hourlyLimit: $scope.hourlyLimitForm
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+
+ if (response.data.status === 1) {
+
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = false;
+ $scope.couldNotConnect = true;
+ $scope.getEmailStats();
+
+ }
+ else
+ {
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = false;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = true;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.changeLimitsForm = false;
+ $scope.changeLimitsFail = true;
+ $scope.changeLimitsSuccess = true;
+ $scope.couldNotConnect = false;
+ }
+ };
+
+ /// Get email logs
+
+ $scope.getLogEntries = function(pageNumber) {
+
+ globalPageNumber = pageNumber;
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/getEmailLogs";
+
+ var data = {
+ page: pageNumber,
+ emailAddress: globalEamilAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $scope.logs = JSON.parse(response.data.data);
+ $scope.listFail = true;
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+ $scope.getLogEntries(1);
+
+
+ $scope.flushLogs = function(emailAddress) {
+
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/flushEmailLogs";
+
+ var data = {
+ emailAddress: emailAddress
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+ $scope.getLogEntries(1);
+
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+
+
+
+});
+
+/* Java script code for Email Page */
\ No newline at end of file
diff --git a/emailPremium/static/emailPremium/settings-gears.png b/emailPremium/static/emailPremium/settings-gears.png
new file mode 100644
index 000000000..34a6f5b0a
Binary files /dev/null and b/emailPremium/static/emailPremium/settings-gears.png differ
diff --git a/emailPremium/static/emailPremium/vpsON.png b/emailPremium/static/emailPremium/vpsON.png
new file mode 100644
index 000000000..14611deab
Binary files /dev/null and b/emailPremium/static/emailPremium/vpsON.png differ
diff --git a/emailPremium/static/emailPremium/vpsOff.png b/emailPremium/static/emailPremium/vpsOff.png
new file mode 100644
index 000000000..e511e68de
Binary files /dev/null and b/emailPremium/static/emailPremium/vpsOff.png differ
diff --git a/emailPremium/templates/emailPremium/emailLimits.html b/emailPremium/templates/emailPremium/emailLimits.html
new file mode 100644
index 000000000..47870f81e
--- /dev/null
+++ b/emailPremium/templates/emailPremium/emailLimits.html
@@ -0,0 +1,221 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{{ domain }} Email Limits - CyberPanel{% endblock %}
+{% block content %}
+
+{% load static %}
+{% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
+
{{ domain }}
+
{% trans "View and change email limits for a domain name." %}
+
+
+ {% if not error %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | Domain |
+ Emails Accounts |
+ Monthly Limit |
+ Monthly Used |
+ Limit Status |
+ Operations |
+
+
+
+
+
+ {{ domain }} |
+ {{ emailAccounts }} |
+ {{ monthlyLimit }} |
+ {{ monthlyUsed }} |
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | Email |
+ Monthly Limit |
+ Monthly Used |
+ Hourly Limit |
+ Hourly Used |
+ Limit Status |
+ Operations |
+
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}
+
+
+
+
+
+
+
+
+
+
+
+
+ {% else %}
+
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/emailPremium/templates/emailPremium/emailPage.html b/emailPremium/templates/emailPremium/emailPage.html
new file mode 100644
index 000000000..e7a947bc4
--- /dev/null
+++ b/emailPremium/templates/emailPremium/emailPage.html
@@ -0,0 +1,228 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{{ emailAddress }} Limits - CyberPanel{% endblock %}
+{% block content %}
+
+{% load static %}
+{% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
+
{{ emailAddress }}
+
{% trans "View and change limits for an Email Address." %}
+
+
+ {% if not error %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | ID |
+ Source |
+ Destination |
+ Time |
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}
+
+
+
+
+
+
+
+
+
+
+
+
+ {% else %}
+
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/emailPremium/templates/emailPremium/listDomains.html b/emailPremium/templates/emailPremium/listDomains.html
new file mode 100644
index 000000000..9bedac9e7
--- /dev/null
+++ b/emailPremium/templates/emailPremium/listDomains.html
@@ -0,0 +1,90 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{% trans "Domains - CyberPanel" %}{% endblock %}
+{% block content %}
+
+{% load static %}
+{% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
+
+
{% trans "List Domains" %}
+
{% trans "On this page you manage emails limits for Domains/Email Addresses" %}
+
+
+
+
+
+ {% trans "Domains" %}
+
+
+
+
+
+
+ | Domain |
+ Emails Accounts |
+ Monthly Limit |
+ Monthly Used |
+ Limit Status |
+ Operations |
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/emailPremium/tests.py b/emailPremium/tests.py
new file mode 100644
index 000000000..5982e6bcd
--- /dev/null
+++ b/emailPremium/tests.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/emailPremium/urls.py b/emailPremium/urls.py
new file mode 100644
index 000000000..7e42bf025
--- /dev/null
+++ b/emailPremium/urls.py
@@ -0,0 +1,28 @@
+from django.conf.urls import url
+import views
+
+urlpatterns = [
+
+ url(r'^listDomains$', views.listDomains, name='listDomains'),
+ url(r'^getFurtherDomains$', views.getFurtherDomains, name='getFurtherDomains'),
+ url(r'^enableDisableEmailLimits$', views.enableDisableEmailLimits, name='enableDisableEmailLimits'),
+
+ url(r'^(?P
([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=]{1}[\da-z\.-]+)*[\/\?]?)$', views.emailLimits, name='emailLimits'),
+ url(r'^changeDomainLimit$', views.changeDomainLimit, name='changeDomainLimit'),
+ url(r'^getFurtherEmail$', views.getFurtherEmail, name='getFurtherEmail'),
+
+ url(r'^enableDisableIndividualEmailLimits$', views.enableDisableIndividualEmailLimits, name='enableDisableIndividualEmailLimits'),
+
+ url(r'(?P\w+@.+)', views.emailPage, name='emailPage'),
+ url(r'^getEmailStats$', views.getEmailStats, name='getEmailStats'),
+
+
+ url(r'^enableDisableIndividualEmailLogs$', views.enableDisableIndividualEmailLogs, name='enableDisableIndividualEmailLogs'),
+ url(r'^changeDomainEmailLimitsIndividual$', views.changeDomainEmailLimitsIndividual, name='changeDomainEmailLimitsIndividual'),
+ url(r'^getEmailLogs$', views.getEmailLogs, name='getEmailLogs'),
+ url(r'^flushEmailLogs$', views.flushEmailLogs, name='flushEmailLogs'),
+
+
+
+
+]
\ No newline at end of file
diff --git a/emailPremium/views.py b/emailPremium/views.py
new file mode 100644
index 000000000..c11a07dc6
--- /dev/null
+++ b/emailPremium/views.py
@@ -0,0 +1,575 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+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 websiteFunctions.models import Websites
+from loginSystem.views import loadLoginPage
+import plogical.CyberCPLogFileWriter as logging
+import json
+from .models import DomainLimits, EmailLimits, EmailLogs
+from math import ceil
+from postfixSenderPolicy.client import cacheClient
+
+
+# Create your views here.
+
+def listDomains(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)
+
+
+ pages = float(len(websites)) / float(10)
+ pagination = []
+
+ if pages <= 1.0:
+ pages = 1
+ pagination.append('')
+ else:
+ pages = ceil(pages)
+ finalPages = int(pages) + 1
+
+ for i in range(1, finalPages):
+ pagination.append('' + str(i) + '')
+
+
+ return render(request,'emailPremium/listDomains.html',{"pagination":pagination})
+
+ except BaseException, msg:
+ logging.CyberCPLogFileWriter.writeToFile(str(msg))
+ return HttpResponse("See CyberCP main log file.")
+
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def getFurtherDomains(request):
+ try:
+ val = request.session['userID']
+
+ try:
+
+ admin = Administrator.objects.get(pk=request.session['userID'])
+
+ if request.method == 'POST':
+ try:
+ data = json.loads(request.body)
+ status = data['page']
+ pageNumber = int(status)
+
+ except BaseException, msg:
+ status = str(msg)
+
+
+ if admin.type == 1:
+ finalPageNumber = ((pageNumber * 10))-10
+ endPageNumber = finalPageNumber + 10
+ websites = Websites.objects.all()[finalPageNumber:endPageNumber]
+
+ else:
+ finalPageNumber = ((pageNumber * 10)) - 10
+ endPageNumber = finalPageNumber + 10
+ websites = Websites.objects.filter(admin=admin)[finalPageNumber:endPageNumber]
+
+ json_data = "["
+ checker = 0
+
+ for items in websites:
+
+ try:
+ domain = Domains.objects.get(domainOwner=items)
+ domainLimits = DomainLimits.objects.get(domain=domain)
+
+ dic = {'domain': items.domain, 'emails': domain.eusers_set.all().count(),
+ 'monthlyLimit': domainLimits.monthlyLimit, 'monthlyUsed': domainLimits.monthlyUsed,
+ 'status':domainLimits.limitStatus}
+
+ if checker == 0:
+ json_data = json_data + json.dumps(dic)
+ checker = 1
+ else:
+ json_data = json_data +',' + json.dumps(dic)
+ except BaseException, msg:
+ logging.CyberCPLogFileWriter.writeToFile(str(msg))
+
+ json_data = json_data + ']'
+ final_dic = {'listWebSiteStatus': 1, 'error_message': "None", "data": json_data}
+ final_json = json.dumps(final_dic)
+
+
+ return HttpResponse(final_json)
+
+ except BaseException,msg:
+ dic = {'listWebSiteStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+
+ except KeyError,msg:
+ dic = {'listWebSiteStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+def enableDisableEmailLimits(request):
+ try:
+ val = request.session['userID']
+ try:
+ if request.method == 'POST':
+
+ admin = Administrator.objects.get(pk=request.session['userID'])
+ data = json.loads(request.body)
+ operationVal = data['operationVal']
+ domainName = data['domainName']
+
+ domain = Domains.objects.get(domain=domainName)
+
+ domainLimits = DomainLimits.objects.get(domain=domain)
+ domainLimits.limitStatus = operationVal
+ domainLimits.save()
+
+ command = 'cyberpanelCleaner purgeLimitDomain ' + domainName + ' ' + str(operationVal)
+ cacheClient.handleCachePurgeRequest(command)
+
+
+ dic = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ except BaseException,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+
+ except KeyError,msg:
+ dic = {'statusa': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+def emailLimits(request,domain):
+ try:
+ val = request.session['userID']
+
+ admin = Administrator.objects.get(pk=val)
+
+
+ if Websites.objects.filter(domain=domain).exists():
+ if admin.type == 1:
+ website = Websites.objects.get(domain=domain)
+ domainEmail = Domains.objects.get(domainOwner=website)
+ domainLimits = DomainLimits.objects.get(domain=domainEmail)
+
+ Data = {}
+ Data['domain'] = domain
+ Data['monthlyLimit'] = domainLimits.monthlyLimit
+ Data['monthlyUsed'] = domainLimits.monthlyUsed
+ Data['emailAccounts'] = domainEmail.eusers_set.count()
+
+ if domainLimits.limitStatus == 1:
+ Data['limitsOn'] = 1
+ Data['limitsOff'] = 0
+ else:
+ Data['limitsOn'] = 0
+ Data['limitsOff'] = 1
+
+
+ ## Pagination for emails
+
+
+ pages = float(Data['emailAccounts']) / float(10)
+ pagination = []
+
+ if pages <= 1.0:
+ pages = 1
+ pagination.append('')
+ else:
+ pages = ceil(pages)
+ finalPages = int(pages) + 1
+
+ for i in range(1, finalPages):
+ pagination.append('' + str(i) + '')
+
+ Data['pagination'] = pagination
+
+
+ return render(request, 'emailPremium/emailLimits.html', Data)
+ else:
+ return render(request, 'emailPremium/emailLimits.html',
+ {"error": 1, "domain": "You do not own this domain."})
+
+ else:
+ return render(request, 'emailPremium/emailLimits.html', {"error":1,"domain": "This domain does not exists"})
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def changeDomainLimit(request):
+ try:
+ val = request.session['userID']
+ try:
+ if request.method == 'POST':
+
+ admin = Administrator.objects.get(pk=request.session['userID'])
+ data = json.loads(request.body)
+ newLimit = data['newLimit']
+ domainName = data['domainName']
+
+ domain = Domains.objects.get(domain=domainName)
+
+ domainLimits = DomainLimits.objects.get(domain=domain)
+ domainLimits.monthlyLimit = newLimit
+ domainLimits.save()
+
+ command = 'cyberpanelCleaner updateDomainLimit ' + domainName + ' ' + str(newLimit)
+ cacheClient.handleCachePurgeRequest(command)
+
+ dic = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ except BaseException,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+
+ except KeyError,msg:
+ dic = {'statusa': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+def getFurtherEmail(request):
+ try:
+ val = request.session['userID']
+ try:
+ if request.method == 'POST':
+ admin = Administrator.objects.get(pk=request.session['userID'])
+ data = json.loads(request.body)
+ status = data['page']
+ domainName = data['domainName']
+ pageNumber = int(status)
+
+ finalPageNumber = ((pageNumber * 10)) - 10
+ endPageNumber = finalPageNumber + 10
+ domain = Domains.objects.get(domain=domainName)
+ emails = domain.eusers_set.all()[finalPageNumber:endPageNumber]
+
+ json_data = "["
+ checker = 0
+
+ for item in emails:
+
+ try:
+ emailLts = EmailLimits.objects.get(email=item)
+
+ dic = {'email': item.email, 'monthlyLimit': emailLts.monthlyLimits,
+ 'monthlyUsed': emailLts.monthlyUsed, 'hourlyLimit': emailLts.hourlyLimit,
+ 'hourlyUsed':emailLts.hourlyUsed,'status': emailLts.limitStatus}
+
+ if checker == 0:
+ json_data = json_data + json.dumps(dic)
+ checker = 1
+ else:
+ json_data = json_data +',' + json.dumps(dic)
+ except BaseException, msg:
+ logging.CyberCPLogFileWriter.writeToFile(str(msg))
+
+ json_data = json_data + ']'
+ final_dic = {'status': 1, 'error_message': "None", "data": json_data}
+ final_json = json.dumps(final_dic)
+
+
+ return HttpResponse(final_json)
+
+ except BaseException,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+
+ except KeyError,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+def enableDisableIndividualEmailLimits(request):
+ try:
+ val = request.session['userID']
+ try:
+ if request.method == 'POST':
+
+ data = json.loads(request.body)
+ operationVal = data['operationVal']
+ emailAddress = data['emailAddress']
+
+ email = EUsers.objects.get(email=emailAddress)
+ emailtLts = EmailLimits.objects.get(email=email)
+ emailtLts.limitStatus = operationVal
+ emailtLts.save()
+
+ command = 'cyberpanelCleaner purgeLimit ' + emailAddress + ' ' + str(operationVal)
+ cacheClient.handleCachePurgeRequest(command)
+
+ dic = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ except BaseException,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ except KeyError,msg:
+ dic = {'statusa': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+def emailPage(request, emailAddress):
+ try:
+ val = request.session['userID']
+
+ admin = Administrator.objects.get(pk=val)
+
+ Data = {}
+ Data['emailAddress'] = emailAddress
+
+ email = EUsers.objects.get(email=emailAddress)
+ logEntries = email.emaillogs_set.all().count()
+
+ pages = float(logEntries) / float(10)
+ pagination = []
+
+ if pages <= 1.0:
+ pages = 1
+ pagination.append('')
+ else:
+ pages = ceil(pages)
+ finalPages = int(pages) + 1
+
+ for i in range(1, finalPages):
+ pagination.append('' + str(i) + '')
+
+ Data['pagination'] = pagination
+
+ return render(request, 'emailPremium/emailPage.html', Data)
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def getEmailStats(request):
+ try:
+ val = request.session['userID']
+ try:
+ if request.method == 'POST':
+ admin = Administrator.objects.get(pk=request.session['userID'])
+ data = json.loads(request.body)
+ emailAddress = data['emailAddress']
+
+ email = EUsers.objects.get(email=emailAddress)
+ emailLTS = EmailLimits.objects.get(email=email)
+
+
+ final_dic = {'status': 1, 'error_message': "None", "monthlyLimit": emailLTS.monthlyLimits,
+ 'monthlyUsed': emailLTS.monthlyUsed, 'hourlyLimit': emailLTS.hourlyLimit,
+ 'hourlyUsed': emailLTS.hourlyUsed,
+ 'limitStatus': emailLTS.limitStatus, 'logsStatus': emailLTS.emailLogs}
+
+ final_json = json.dumps(final_dic)
+
+
+ return HttpResponse(final_json)
+
+ except BaseException,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+
+ except KeyError,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+def enableDisableIndividualEmailLogs(request):
+ try:
+ val = request.session['userID']
+ try:
+ if request.method == 'POST':
+
+ data = json.loads(request.body)
+ operationVal = data['operationVal']
+ emailAddress = data['emailAddress']
+
+ email = EUsers.objects.get(email=emailAddress)
+ emailtLts = EmailLimits.objects.get(email=email)
+ emailtLts.emailLogs = operationVal
+ emailtLts.save()
+
+ command = 'cyberpanelCleaner purgeLog ' + emailAddress + ' ' + str(operationVal)
+ cacheClient.handleCachePurgeRequest(command)
+
+ dic = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ except BaseException,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ except KeyError,msg:
+ dic = {'statusa': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+def changeDomainEmailLimitsIndividual(request):
+ try:
+ val = request.session['userID']
+ try:
+ if request.method == 'POST':
+
+ admin = Administrator.objects.get(pk=request.session['userID'])
+ data = json.loads(request.body)
+ emailAddress = data['emailAddress']
+ monthlyLimit = data['monthlyLimit']
+ hourlyLimit = data['hourlyLimit']
+
+ ## Limits Check
+
+ if monthlyLimit < hourlyLimit:
+ dic = {'status': 0, 'error_message': 'Monthly limit should be greater then hourly limit.'}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ domainName = emailAddress.split('@')[1]
+ dbDomain = Domains.objects.get(domain=domainName)
+
+ domainLimit = DomainLimits.objects.get(domain=dbDomain)
+
+ allEmails = dbDomain.eusers_set.all()
+ currentEmailConsumption = 0
+
+ for email in allEmails:
+ emailLTS = EmailLimits.objects.get(email=email)
+ currentEmailConsumption = emailLTS.monthlyLimits + currentEmailConsumption
+
+
+ allowedLimit = domainLimit.monthlyLimit - currentEmailConsumption
+
+ if monthlyLimit > allowedLimit:
+ dic = {'status': 0, 'error_message': 'You can not set this monthly limit, first increase limits for this domain.'}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ ## Limits Check End
+
+ email = EUsers.objects.get(email=emailAddress)
+ emailLTS = EmailLimits.objects.get(email=email)
+
+ emailLTS.monthlyLimits = monthlyLimit
+ emailLTS.hourlyLimit = hourlyLimit
+
+ emailLTS.save()
+
+ command = 'cyberpanelCleaner purgeLimitEmail ' + emailAddress + ' ' + str(monthlyLimit) + ' ' + str(hourlyLimit)
+ cacheClient.handleCachePurgeRequest(command)
+
+ dic = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ except BaseException,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+
+ except KeyError,msg:
+ dic = {'statusa': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+def getEmailLogs(request):
+ try:
+ val = request.session['userID']
+ try:
+ if request.method == 'POST':
+
+ admin = Administrator.objects.get(pk=request.session['userID'])
+ data = json.loads(request.body)
+ status = data['page']
+ emailAddress = data['emailAddress']
+ pageNumber = int(status)
+
+ finalPageNumber = ((pageNumber * 10)) - 10
+ endPageNumber = finalPageNumber + 10
+ email = EUsers.objects.get(email=emailAddress)
+ logEntries = email.emaillogs_set.all()[finalPageNumber:endPageNumber]
+
+ json_data = "["
+ checker = 0
+
+ for item in logEntries:
+
+ dic = {'id': item.id, 'source': emailAddress, 'destination':item.destination,
+ 'time': item.timeStamp}
+
+ 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, 'error_message': "None", "data": json_data}
+ final_json = json.dumps(final_dic)
+
+
+ return HttpResponse(final_json)
+
+ except BaseException,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+
+ except KeyError,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+def flushEmailLogs(request):
+ try:
+ val = request.session['userID']
+ try:
+ if request.method == 'POST':
+
+ data = json.loads(request.body)
+ emailAddress = data['emailAddress']
+
+ email = EUsers.objects.get(email=emailAddress)
+
+ for logEntry in email.emaillogs_set.all():
+ logEntry.delete()
+
+ dic = {'status': 1, 'error_message': 'None'}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ except BaseException,msg:
+ dic = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ except KeyError,msg:
+ dic = {'statusa': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
\ No newline at end of file
diff --git a/filemanager/__init__.pyc b/filemanager/__init__.pyc
index 6951e53e3..d0a0bb55b 100644
Binary files a/filemanager/__init__.pyc and b/filemanager/__init__.pyc differ
diff --git a/filemanager/admin.pyc b/filemanager/admin.pyc
index df5374762..86509b43e 100644
Binary files a/filemanager/admin.pyc and b/filemanager/admin.pyc differ
diff --git a/filemanager/models.pyc b/filemanager/models.pyc
index 2f5b0f198..2340adb68 100644
Binary files a/filemanager/models.pyc and b/filemanager/models.pyc differ
diff --git a/firewall/__init__.pyc b/firewall/__init__.pyc
index b3cebf703..1f20018be 100644
Binary files a/firewall/__init__.pyc and b/firewall/__init__.pyc differ
diff --git a/firewall/admin.pyc b/firewall/admin.pyc
index 4a7e86e1f..ecf710338 100644
Binary files a/firewall/admin.pyc and b/firewall/admin.pyc differ
diff --git a/firewall/models.pyc b/firewall/models.pyc
index 31f9975ea..dbee7d1de 100644
Binary files a/firewall/models.pyc and b/firewall/models.pyc differ
diff --git a/firewall/templates/firewall/spamassassin.html b/firewall/templates/firewall/spamassassin.html
new file mode 100644
index 000000000..ac0b19c47
--- /dev/null
+++ b/firewall/templates/firewall/spamassassin.html
@@ -0,0 +1,200 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{% trans "SpamAssassin - CyberPanel" %}{% endblock %}
+{% block content %}
+
+{% load static %}
+{% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
+
{% trans "SpamAssassin Configurations!" %}
+
{% trans "On this page you can configure SpamAssassin settings." %}
+
+
+
+
+
+
+
+
+
+ {% if modSecInstalled == 0 %}
+
+
+
{% trans "ModSecurity is not installed " %}
+
+
+
+
+
+
+
+
+
+
+
+
+ {% else %}
+
+
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/firewall/urls.py b/firewall/urls.py
index d580b7632..aede4bf14 100644
--- a/firewall/urls.py
+++ b/firewall/urls.py
@@ -40,5 +40,10 @@ urlpatterns = [
url(r'^enableDisableRuleFile', views.enableDisableRuleFile, name='enableDisableRuleFile'),
+ ## SpamAssassin
+
+ url(r'^spamAssassin', views.spamAssassin, name='spamAssassin'),
+
+
]
\ No newline at end of file
diff --git a/firewall/views.py b/firewall/views.py
index 81d6269db..be753b042 100644
--- a/firewall/views.py
+++ b/firewall/views.py
@@ -37,6 +37,19 @@ def firewallHome(request):
except KeyError:
return redirect(loadLoginPage)
+def spamAssassin(request):
+ try:
+ userID = request.session['userID']
+
+ admin = Administrator.objects.get(pk=userID)
+
+ if admin.type == 3:
+ return HttpResponse("You don't have enough priviliges to access this page.")
+
+ return render(request,'firewall/spamassassin.html')
+ except KeyError:
+ return redirect(loadLoginPage)
+
def getCurrentRules(request):
diff --git a/ftp/__init__.pyc b/ftp/__init__.pyc
index d4609ae24..c8cd50973 100644
Binary files a/ftp/__init__.pyc and b/ftp/__init__.pyc differ
diff --git a/ftp/admin.pyc b/ftp/admin.pyc
index c33a0295d..c96164709 100644
Binary files a/ftp/admin.pyc and b/ftp/admin.pyc differ
diff --git a/ftp/models.pyc b/ftp/models.pyc
index 64b88c626..abf4d6b2a 100644
Binary files a/ftp/models.pyc and b/ftp/models.pyc differ
diff --git a/loginSystem/__init__.pyc b/loginSystem/__init__.pyc
index f65734b59..01cc49069 100644
Binary files a/loginSystem/__init__.pyc and b/loginSystem/__init__.pyc differ
diff --git a/loginSystem/admin.pyc b/loginSystem/admin.pyc
index f852b0ed2..aa96d38dc 100644
Binary files a/loginSystem/admin.pyc and b/loginSystem/admin.pyc differ
diff --git a/loginSystem/models.pyc b/loginSystem/models.pyc
index a0669655b..852423c6c 100644
Binary files a/loginSystem/models.pyc and b/loginSystem/models.pyc differ
diff --git a/mailServer/__init__.pyc b/mailServer/__init__.pyc
index 49c4c226a..b3308106c 100644
Binary files a/mailServer/__init__.pyc and b/mailServer/__init__.pyc differ
diff --git a/mailServer/admin.pyc b/mailServer/admin.pyc
index 467828123..290d4ea6b 100644
Binary files a/mailServer/admin.pyc and b/mailServer/admin.pyc differ
diff --git a/mailServer/models.py b/mailServer/models.py
index 51cfd00a4..4fce00d2b 100644
--- a/mailServer/models.py
+++ b/mailServer/models.py
@@ -26,7 +26,6 @@ class EUsers(models.Model):
class Meta:
db_table = 'e_users'
-
class Forwardings(models.Model):
source = models.CharField(max_length=80)
destination = models.TextField()
diff --git a/mailServer/models.pyc b/mailServer/models.pyc
index 3d8d40b5d..be9900f8f 100644
Binary files a/mailServer/models.pyc and b/mailServer/models.pyc differ
diff --git a/mailServer/urls.py b/mailServer/urls.py
index 567a27a56..a438552a1 100644
--- a/mailServer/urls.py
+++ b/mailServer/urls.py
@@ -33,4 +33,5 @@ urlpatterns = [
url(r'^installOpenDKIM', views.installOpenDKIM, name='installOpenDKIM'),
url(r'^installStatusOpenDKIM', views.installStatusOpenDKIM, name='installStatusOpenDKIM'),
+
]
\ No newline at end of file
diff --git a/mailServer/views.py b/mailServer/views.py
index 857d11f4d..26e0b7447 100644
--- a/mailServer/views.py
+++ b/mailServer/views.py
@@ -118,7 +118,6 @@ def deleteEmailAccount(request):
return redirect(loadLoginPage)
-
def getEmailsForDomain(request):
try:
val = request.session['userID']
@@ -128,15 +127,18 @@ def getEmailsForDomain(request):
data = json.loads(request.body)
domain = data['domain']
- domain = Domains.objects.get(domain=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)
emails = domain.eusers_set.all()
if emails.count() == 0:
- final_dic = {'fetchStatus': 0, 'error_message': "No email accounts exits"}
-
+ final_dic = {'fetchStatus': 0, 'error_message': "No email accounts exists!"}
final_json = json.dumps(final_dic)
-
return HttpResponse(final_json)
json_data = "["
@@ -621,3 +623,4 @@ def installStatusOpenDKIM(request):
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
+
diff --git a/managePHP/__init__.pyc b/managePHP/__init__.pyc
index 6142ce7e2..6735fa8d3 100644
Binary files a/managePHP/__init__.pyc and b/managePHP/__init__.pyc differ
diff --git a/managePHP/admin.pyc b/managePHP/admin.pyc
index 272a18a6d..40627624a 100644
Binary files a/managePHP/admin.pyc and b/managePHP/admin.pyc differ
diff --git a/managePHP/models.pyc b/managePHP/models.pyc
index ea173e711..6a3913048 100644
Binary files a/managePHP/models.pyc and b/managePHP/models.pyc differ
diff --git a/managePHP/templates/managePHP/installExtensions.html b/managePHP/templates/managePHP/installExtensions.html
index e415e9dbb..55d3ca13b 100644
--- a/managePHP/templates/managePHP/installExtensions.html
+++ b/managePHP/templates/managePHP/installExtensions.html
@@ -48,7 +48,7 @@
-
+
diff --git a/manageSSL/__init__.pyc b/manageSSL/__init__.pyc
index 9919c9f70..db3dce59c 100644
Binary files a/manageSSL/__init__.pyc and b/manageSSL/__init__.pyc differ
diff --git a/manageSSL/admin.pyc b/manageSSL/admin.pyc
index 3fe69d414..dcae0c444 100644
Binary files a/manageSSL/admin.pyc and b/manageSSL/admin.pyc differ
diff --git a/manageSSL/models.pyc b/manageSSL/models.pyc
index 771436811..fd03e7ed0 100644
Binary files a/manageSSL/models.pyc and b/manageSSL/models.pyc differ
diff --git a/packages/__init__.pyc b/packages/__init__.pyc
index 608d3b0df..c28d9f99e 100644
Binary files a/packages/__init__.pyc and b/packages/__init__.pyc differ
diff --git a/packages/admin.pyc b/packages/admin.pyc
index 5cc47c1e5..5d6a2c515 100644
Binary files a/packages/admin.pyc and b/packages/admin.pyc differ
diff --git a/packages/models.pyc b/packages/models.pyc
index 1bf311c4e..c07b42338 100644
Binary files a/packages/models.pyc and b/packages/models.pyc differ
diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py
index cc9f3e29d..5ebb6d40b 100644
--- a/plogical/mailUtilities.py
+++ b/plogical/mailUtilities.py
@@ -10,6 +10,7 @@ import subprocess
import argparse
import shlex
from mailServer.models import Domains,EUsers
+from emailPremium.models import DomainLimits, EmailLimits
from websiteFunctions.models import Websites
@@ -35,8 +36,13 @@ class mailUtilities:
try:
- newEmailDomain = Domains(domainOwner=website, domain=domain)
- newEmailDomain.save()
+ if not Domains.objects.filter(domain=domain).exists():
+ newEmailDomain = Domains(domainOwner=website, domain=domain)
+ newEmailDomain.save()
+
+ if not DomainLimits.objects.filter(domain=newEmailDomain).exists():
+ domainLimits = DomainLimits(domain=newEmailDomain)
+ domainLimits.save()
if website.package.emailAccounts == 0 or (
newEmailDomain.eusers_set.all().count() < website.package.emailAccounts):
@@ -87,6 +93,9 @@ class mailUtilities:
emailAcct = EUsers(emailOwner=emailDomain, email=finalEmailUsername, password=password)
emailAcct.save()
+ emailLimits = EmailLimits(email=emailAcct)
+ emailLimits.save()
+
print "1,None"
return 1,"None"
diff --git a/plogical/upgrade.py b/plogical/upgrade.py
index 1c31ace02..fdd4d9bf2 100644
--- a/plogical/upgrade.py
+++ b/plogical/upgrade.py
@@ -1,5 +1,3 @@
-import thread
-import tarfile
import os
import shlex
import subprocess
@@ -18,7 +16,7 @@ class Upgrade:
data = json.loads(r.text)
version_number = str(data['version'])
version_build = str(data['build'])
- return (version_number + "." + version_build + ".tar.gz")
+ return ("Temp.tar.gz")
@@ -31,7 +29,7 @@ class Upgrade:
## Download latest version.
- command = "wget https://cyberpanel.net/CyberPanel." + versionNumbring
+ command = "wget https://cyberpanel.net/CyberPanel" + versionNumbring
subprocess.call(shlex.split(command))
## Backup settings file.
@@ -45,7 +43,7 @@ class Upgrade:
## Extract Latest files
- command = "tar zxf CyberPanel." + versionNumbring
+ command = "tar zxf CyberPanel" + versionNumbring
subprocess.call(shlex.split(command))
## Copy settings file
@@ -84,6 +82,13 @@ class Upgrade:
command = "chmod -R 777 /usr/local/lsws/Example/html/FileManager"
subprocess.call(shlex.split(command))
+ ## MailServer Model Changes
+
+ os.chdir('/usr/local/CyberCP')
+
+ command = "echo 'ALTER TABLE e_forwardings DROP PRIMARY KEY;ALTER TABLE e_forwardings ADD id INT AUTO_INCREMENT PRIMARY KEY;' | python manage.py dbshell"
+ subprocess.check_output(command, shell=True)
+
## Restart Gunicorn
command = "systemctl restart gunicorn.socket"
@@ -98,4 +103,6 @@ class Upgrade:
print("Upgrade Completed.")
+
+
Upgrade.upgrade()
\ No newline at end of file
diff --git a/postfixSenderPolicy/__init__.py b/postfixSenderPolicy/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/postfixSenderPolicy/__pycache__/rawFileParser.cpython-36.pyc b/postfixSenderPolicy/__pycache__/rawFileParser.cpython-36.pyc
new file mode 100755
index 000000000..60cab8dab
Binary files /dev/null and b/postfixSenderPolicy/__pycache__/rawFileParser.cpython-36.pyc differ
diff --git a/postfixSenderPolicy/accept_traffic.py b/postfixSenderPolicy/accept_traffic.py
new file mode 100755
index 000000000..e77ed7d80
--- /dev/null
+++ b/postfixSenderPolicy/accept_traffic.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python2.7
+import os,sys
+sys.path.append('/usr/local/CyberCP')
+import django
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
+django.setup()
+import threading as multi
+from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
+from policyConstraint import policyConstraints
+from emailPremium.models import DomainLimits, EmailLimits, EmailLogs
+from mailServer.models import Domains, EUsers
+import time
+from cacheManager import cacheManager
+
+limitThreads = multi.BoundedSemaphore(10)
+
+class HandleRequest(multi.Thread):
+ def __init__(self, conn):
+ multi.Thread.__init__(self)
+ self.connection = conn
+
+ def run(self):
+ limitThreads.acquire()
+ dataComplete = ""
+ try:
+ try:
+
+ while True:
+ Data = self.connection.recv(64)
+ if Data:
+ if len(Data) < 64:
+ dataComplete = dataComplete + Data
+
+ if dataComplete.find('cyberpanelCleaner') > -1:
+ logging.writeToFile(dataComplete)
+ cacheManager.handlePurgeRequest(dataComplete)
+ else:
+ self.manageRequest(dataComplete)
+
+ dataComplete = ''
+ else:
+ dataComplete = dataComplete + Data
+ else:
+ self.connection.close()
+ finally:
+ # Clean up the connection
+ self.connection.close()
+
+ finally:
+ limitThreads.release()
+
+ def manageRequest(self, completeData):
+ try:
+ completeData = completeData.split('\n')
+
+ for items in completeData:
+ tempData = items.split('=')
+ if tempData[0] == 'client_name':
+ domainName = tempData[1]
+ elif tempData[0] == 'sender':
+ emailAddress = tempData[1]
+ elif tempData[0] == 'recipient':
+ destination = tempData[1]
+
+ if domainName in cacheManager.domains:
+ domainObj = cacheManager.domains[domainName]
+ emailObj = domainObj.findEmailOBJ(emailAddress)
+ else:
+ domain = Domains.objects.get(domain=domainName)
+ domainLTS = DomainLimits.objects.get(domain=domain)
+
+ newDomain = policyConstraints(domainName, domainLTS.monthlyLimit, domainLTS.monthlyUsed, domainLTS.limitStatus)
+ cacheManager.domains[domainName] = newDomain
+ domainObj = newDomain
+
+ emailObj = newDomain.findEmailOBJ(emailAddress)
+
+ #logging.writeToFile('Domain Limit Status: ' + str(domainObj.limitStatus))
+ #logging.writeToFile('Email Limit Status: ' + str(domainObj.limitStatus))
+ #logging.writeToFile('Email Monthly Limit: ' + str(emailObj.monthlyLimits))
+ #logging.writeToFile('Email Monthly Used: ' + str(emailObj.monthlyUsed))
+
+ if domainObj.limitStatus == 1 and emailObj.limitStatus == 1:
+ if emailObj.monthlyLimits < emailObj.monthlyUsed or emailObj.hourlyLimits < emailObj.hourlyUsed:
+ logging.writeToFile(emailAddress + ' either exceeded monthly or hourly sending limit.')
+ self.connection.sendall('action=defer_if_permit Service temporarily unavailable\n\n')
+ else:
+ email = EUsers.objects.get(email=emailAddress)
+ if emailObj.logStatus == 1:
+ logEntry = EmailLogs(email=email, destination=destination, timeStamp=time.strftime("%I-%M-%S-%a-%b-%Y"))
+ logEntry.save()
+ emailObj.monthlyUsed = emailObj.monthlyUsed + 1
+ emailObj.hourlyUsed = emailObj.hourlyUsed + 1
+ self.connection.sendall('action=dunno\n\n')
+ else:
+ email = EUsers.objects.get(email=emailAddress)
+ if emailObj.logStatus == 1:
+ logEntry = EmailLogs(email=email, destination=destination,
+ timeStamp=time.strftime("%I-%M-%S-%a-%b-%Y"))
+ logEntry.save()
+ emailObj.monthlyUsed = emailObj.monthlyUsed + 1
+ emailObj.hourlyUsed = emailObj.hourlyUsed + 1
+ self.connection.sendall('action=dunno\n\n')
+
+
+ except BaseException, msg:
+ self.connection.sendall('action=dunno\n\n')
+ logging.writeToFile(str(msg))
diff --git a/postfixSenderPolicy/cacheManager.py b/postfixSenderPolicy/cacheManager.py
new file mode 100755
index 000000000..a0bb00edd
--- /dev/null
+++ b/postfixSenderPolicy/cacheManager.py
@@ -0,0 +1,198 @@
+#!/usr/bin/env python2.7
+import os,sys
+sys.path.append('/usr/local/CyberCP')
+import django
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
+django.setup()
+sys.path.append('/usr/local/CyberCP')
+from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
+from emailPremium.models import EmailLimits, DomainLimits, Domains, EUsers
+
+class cacheManager:
+ domains = {}
+
+ @staticmethod
+ def flushCache():
+ try:
+
+ for domain, domainOBJ in cacheManager.domains.iteritems():
+ domaindb = Domains.objects.get(domain=domain)
+ dbDomain = DomainLimits.objects.get(domain=domaindb)
+
+ totalDomainUsed = 0
+
+ for email, emailOBJ in domainOBJ.emails.iteritems():
+ emailID = EUsers.objects.get(email=email)
+ dbEmail = EmailLimits.objects.get(email=emailID)
+
+ dbEmail.monthlyUsed = emailOBJ.monthlyUsed
+ dbEmail.hourlyUsed = emailOBJ.hourlyUsed
+
+ totalDomainUsed = totalDomainUsed + emailOBJ.monthlyUsed
+ dbEmail.save()
+
+ dbDomain.monthlyUsed = totalDomainUsed
+ dbDomain.save()
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+ @staticmethod
+ def disableEnableLogs(self, emailAddress, operationValue):
+ try:
+ domainName = emailAddress.split('@')[1]
+
+ if domainName in cacheManager.domains:
+ domainOBJ = cacheManager.domains[domainName]
+ if emailAddress in domainOBJ.emails:
+ emailOBJ = domainOBJ.emails[emailAddress]
+ emailOBJ.logStatus = operationValue
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+ @staticmethod
+ def purgeLog(command):
+ try:
+ email = command[2]
+ operationVal = int(command[3])
+ domain = email.split('@')[1]
+
+ if domain in cacheManager.domains:
+ domainOBJ = cacheManager.domains[domain]
+ emailOBJ = domainOBJ.emails[email]
+ emailOBJ.logStatus = operationVal
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+ @staticmethod
+ def purgeLimit(command):
+ try:
+ email = command[2]
+ operationVal = int(command[3])
+ domain = email.split('@')[1]
+
+ if domain in cacheManager.domains:
+ domainOBJ = cacheManager.domains[domain]
+ emailOBJ = domainOBJ.emails[email]
+ emailOBJ.limitStatus = operationVal
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+ @staticmethod
+ def purgeLimitDomain(command):
+ try:
+ domain = command[2]
+ operationVal = int(command[3])
+
+ if domain in cacheManager.domains:
+ domainOBJ = cacheManager.domains[domain]
+ domainOBJ.limitStatus = operationVal
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+ @staticmethod
+ def updateDomainLimit(command):
+ try:
+ domain = command[2]
+ newLimit = int(command[3])
+
+ if domain in cacheManager.domains:
+ domainOBJ = cacheManager.domains[domain]
+ domainOBJ.monthlyLimits = newLimit
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+ @staticmethod
+ def purgeLimitEmail(command):
+ try:
+ email = command[2]
+ monthlyLimit = int(command[3])
+ hourlyLimit = int(command[4])
+ domain = email.split('@')[1]
+
+ if domain in cacheManager.domains:
+ domainOBJ = cacheManager.domains[domain]
+ emailOBJ = domainOBJ.emails[email]
+ emailOBJ.monthlyLimits = monthlyLimit
+ emailOBJ.hourlyLimits = hourlyLimit
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+ @staticmethod
+ def hourlyCleanUP():
+ try:
+
+ for domain, domainOBJ in cacheManager.domains.iteritems():
+ for email, emailOBJ in domainOBJ.emails.iteritems():
+ emailID = EUsers.objects.get(email=email)
+ dbEmail = EmailLimits.objects.get(email=emailID)
+
+ dbEmail.hourlyUsed = 0
+ emailOBJ.hourlyUsed = 0
+ dbEmail.save()
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+ @staticmethod
+ def monthlyCleanUP():
+ try:
+
+ for domain, domainOBJ in cacheManager.domains.iteritems():
+ domaindb = Domains.objects.get(domain=domain)
+ dbDomain = DomainLimits.objects.get(domain=domaindb)
+
+
+ for email, emailOBJ in domainOBJ.emails.iteritems():
+ emailID = EUsers.objects.get(email=email)
+ dbEmail = EmailLimits.objects.get(email=emailID)
+
+ dbEmail.monthlyUsed = 0
+ emailOBJ.monthlyUsed = 0
+ dbEmail.hourlyUsed = 0
+ emailOBJ.hourlyUsed = 0
+ dbEmail.save()
+
+ dbDomain.monthlyUsed = 0
+ dbDomain.save()
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+
+ @staticmethod
+ def cleanUP(*args):
+ cacheManager.flushCache()
+ logging.writeToFile('Email Cleanup Service')
+ os._exit(0)
+
+ @staticmethod
+ def handlePurgeRequest(command):
+ try:
+ finalCommand = command.split(' ')
+
+ if finalCommand[1] == 'purgeLog':
+ cacheManager.purgeLog(finalCommand)
+ elif finalCommand[1] == 'purgeLimit':
+ cacheManager.purgeLimit(finalCommand)
+ elif finalCommand[1] == 'purgeLimitDomain':
+ cacheManager.purgeLimitDomain(finalCommand)
+ elif finalCommand[1] == 'updateDomainLimit':
+ cacheManager.updateDomainLimit(finalCommand)
+ elif finalCommand[1] == 'purgeLimitEmail':
+ cacheManager.purgeLimitEmail(finalCommand)
+ elif finalCommand[1] == 'hourlyCleanup':
+ cacheManager.hourlyCleanUP()
+ elif finalCommand[1] == 'monthlyCleanup':
+ cacheManager.monthlyCleanUP()
+
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
diff --git a/postfixSenderPolicy/client.py b/postfixSenderPolicy/client.py
new file mode 100755
index 000000000..98763768d
--- /dev/null
+++ b/postfixSenderPolicy/client.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python2.7
+import socket
+import sys
+sys.path.append('/usr/local/CyberCP')
+from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
+import argparse
+
+class cacheClient:
+ def __init__(self, serverAddr):
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.serverAddr = serverAddr
+ self.sock.connect(self.serverAddr)
+
+ def sendData(self, data):
+ self.sock.sendall(data)
+
+ def __del__(self):
+ self.sock.close()
+
+
+ @staticmethod
+ def handleCachePurgeRequest(command):
+ try:
+ serverAddr = ('localhost', 1089)
+ cachePurger = cacheClient(serverAddr)
+ cachePurger.sendData(command)
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+
+def main():
+
+ parser = argparse.ArgumentParser(description='CyberPanel Email Policy Cache Cleaner')
+ parser.add_argument('function', help='Specific a function to call!')
+
+
+ args = parser.parse_args()
+
+ if args.function == "hourlyCleanup":
+ command = 'cyberpanelCleaner hourlyCleanup'
+ cacheClient.handleCachePurgeRequest(command)
+ elif args.function == 'monthlyCleanup':
+ command = 'cyberpanelCleaner monthlyCleanup'
+ cacheClient.handleCachePurgeRequest(command)
+
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
diff --git a/postfixSenderPolicy/cpecs.service b/postfixSenderPolicy/cpecs.service
new file mode 100755
index 000000000..27bb40665
--- /dev/null
+++ b/postfixSenderPolicy/cpecs.service
@@ -0,0 +1,12 @@
+[Unit]
+Description = CyberPanel Email Policy Control Daemon
+
+[Service]
+Type=forking
+ExecStart = /usr/local/CyberCP/postfixSenderPolicy/policyCTRL.py start
+ExecStop = /usr/local/CyberCP/postfixSenderPolicy/policyCTRL.py stop
+Restart= /usr/local/CyberCP/postfixSenderPolicy/policyCTRL.py restart
+Restart=on-abnormal
+
+[Install]
+WantedBy=default.target
diff --git a/postfixSenderPolicy/policyCTRL.py b/postfixSenderPolicy/policyCTRL.py
new file mode 100755
index 000000000..d80a9fda1
--- /dev/null
+++ b/postfixSenderPolicy/policyCTRL.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python2.7
+import subprocess, signal
+import shlex
+import argparse
+import os
+import sys
+sys.path.append('/usr/local/CyberCP')
+from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
+
+
+class policyCTRL:
+ applicationPath = '/usr/local/CyberCP/postfixSenderPolicy/pid'
+
+ def prepareArguments(self):
+
+ parser = argparse.ArgumentParser(description='CyberPanel Policy Control Parser!')
+ parser.add_argument('function', help='Specific a operation to perform!')
+
+ return parser.parse_args()
+
+ def start(self):
+
+ if os.path.exists(policyCTRL.applicationPath):
+ self.stop()
+
+ command = '/usr/local/CyberCP/postfixSenderPolicy/startServer.py'
+ subprocess.Popen(shlex.split(command))
+
+ def stop(self):
+ path = policyCTRL.applicationPath
+ pid = open(path, "r").readlines()[0]
+ try:
+ os.kill(int(pid), signal.SIGTERM)
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+
+
+def main():
+
+ policy = policyCTRL()
+ args = policy.prepareArguments()
+
+ ## Website functions
+
+ if args.function == "start":
+ policy.start()
+ elif args.function == "stop":
+ policy.stop()
+ elif args.function == "restart":
+ policy.stop()
+ policy.start()
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
diff --git a/postfixSenderPolicy/policyConstraint.py b/postfixSenderPolicy/policyConstraint.py
new file mode 100644
index 000000000..f5ed2ef99
--- /dev/null
+++ b/postfixSenderPolicy/policyConstraint.py
@@ -0,0 +1,33 @@
+from emailPremium.models import DomainLimits, EmailLimits, EmailLogs
+from mailServer.models import Domains, EUsers
+
+class emailConstraints:
+ def __init__(self, emailAddress, monthlyLimits, monthlyUsed, hourlyLimits, hourlyUsed, limitStatus, logStatus):
+ self.emailAddress = emailAddress
+ self.monthlyLimits = monthlyLimits
+ self.monthlyUsed = monthlyUsed
+ self.hourlyLimits = hourlyLimits
+ self.hourlyUsed = hourlyUsed
+ self.limitStatus = limitStatus
+ self.logStatus = logStatus
+
+class policyConstraints:
+ def __init__(self, domain, monthlyLimits, monthlyUsed, limitStatus):
+ self.domain = domain
+ self.emails = {}
+ self.monthlyLimits = monthlyLimits
+ self.monthlyUsed = monthlyUsed
+ self.limitStatus = limitStatus
+
+
+ def findEmailOBJ(self, emailAddress):
+ if emailAddress in self.emails:
+ return self.emails[emailAddress]
+
+ else:
+ email = EUsers.objects.get(email=emailAddress)
+ emailLTS = EmailLimits.objects.get(email=email)
+ newEmail = emailConstraints(emailAddress, emailLTS.monthlyLimits, emailLTS.monthlyUsed, emailLTS.hourlyLimit,
+ emailLTS.hourlyUsed, emailLTS.limitStatus, emailLTS.emailLogs)
+ self.emails[emailAddress] = newEmail
+ return newEmail
\ No newline at end of file
diff --git a/postfixSenderPolicy/startServer.py b/postfixSenderPolicy/startServer.py
new file mode 100755
index 000000000..ed4156ef9
--- /dev/null
+++ b/postfixSenderPolicy/startServer.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python2.7
+import os,sys
+sys.path.append('/usr/local/CyberCP')
+import django
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
+django.setup()
+import socket
+import os
+import accept_traffic as handle
+from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
+from signal import *
+from cacheManager import cacheManager
+
+
+class SetupConn:
+ server_address = ('localhost', 1089)
+ applicationPath = '/usr/local/CyberCP/postfixSenderPolicy/pid'
+
+
+ def __init__(self, serv_addr):
+ self.server_addr = serv_addr
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+ def setup_conn(self):
+
+ logging.writeToFile('Starting CyberPanel Email Policy Server!')
+ self.sock.bind(SetupConn.server_address)
+ logging.writeToFile('CyberPanel Email Policy Server Successfully started!')
+
+ def start_listening(self):
+ self.sock.listen(1)
+ while True:
+ # Wait for a connection
+ logging.writeToFile('Waiting For Connection!')
+ connection, client_address = self.sock.accept()
+ background = handle.HandleRequest(connection)
+ background.start()
+ def __del__(self):
+ self.sock.close()
+ logging.writeToFile('Closing open connections!')
+
+
+
+def Main():
+ writeToFile = open(SetupConn.applicationPath, 'w')
+ writeToFile.write(str(os.getpid()))
+ writeToFile.close()
+
+ for sig in (SIGABRT, SIGINT, SIGTERM):
+ signal(sig, cacheManager.cleanUP)
+
+ listenConn = SetupConn(SetupConn.server_address)
+ listenConn.setup_conn()
+ listenConn.start_listening()
+
+
+if __name__ == "__main__":
+ Main()
+
diff --git a/serverLogs/__init__.pyc b/serverLogs/__init__.pyc
index 7010da2d8..18b20daef 100644
Binary files a/serverLogs/__init__.pyc and b/serverLogs/__init__.pyc differ
diff --git a/serverLogs/admin.pyc b/serverLogs/admin.pyc
index fb494858d..74f9a9975 100644
Binary files a/serverLogs/admin.pyc and b/serverLogs/admin.pyc differ
diff --git a/serverLogs/models.pyc b/serverLogs/models.pyc
index 8905b554e..485885850 100644
Binary files a/serverLogs/models.pyc and b/serverLogs/models.pyc differ
diff --git a/serverStatus/__init__.pyc b/serverStatus/__init__.pyc
index ab306a8b6..ac32679f2 100644
Binary files a/serverStatus/__init__.pyc and b/serverStatus/__init__.pyc differ
diff --git a/serverStatus/admin.pyc b/serverStatus/admin.pyc
index d3b09cb22..4167df5c2 100644
Binary files a/serverStatus/admin.pyc and b/serverStatus/admin.pyc differ
diff --git a/serverStatus/models.pyc b/serverStatus/models.pyc
index 3e99fa5f0..0cde40360 100644
Binary files a/serverStatus/models.pyc and b/serverStatus/models.pyc differ
diff --git a/static/emailPremium/emailPremium.js b/static/emailPremium/emailPremium.js
new file mode 100644
index 000000000..37b118fd1
--- /dev/null
+++ b/static/emailPremium/emailPremium.js
@@ -0,0 +1,199 @@
+/**
+ * Created by usman on 6/22/18.
+ */
+
+/* Java script code to list accounts */
+
+app.controller('listDomains', function($scope,$http) {
+
+ $scope.listFail = true;
+ $scope.emailLimitsLoading = true;
+
+ // Global page number, to be used in later function to refresh the domains
+ var globalPageNumber;
+
+
+ $scope.getFurtherWebsitesFromDB = function(pageNumber) {
+
+ globalPageNumber = pageNumber;
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/getFurtherDomains";
+
+ var data = {page: pageNumber};
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.listWebSiteStatus === 1) {
+
+ $scope.WebSitesList = JSON.parse(response.data.data);
+ $scope.listFail = true;
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+ $scope.getFurtherWebsitesFromDB(1);
+
+ $scope.enableDisableEmailLimits = function (operationVal, domainName) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ domainName: domainName
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $scope.getFurtherWebsitesFromDB(globalPageNumber);
+ $scope.listFail = true;
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+ }
+});
+
+/* Java script code to list accounts ends here */
+
+
+
+/* Java script code for email domain page */
+
+app.controller('emailDomainPage', function($scope,$http, $timeout, $window) {
+
+ $scope.listFail = true;
+ $scope.emailLimitsLoading = true;
+
+ // Global page number, to be used in later function to refresh the domains
+ var globalPageNumber;
+
+
+ $scope.getFurtherWebsitesFromDB = function(pageNumber) {
+
+ globalPageNumber = pageNumber;
+ $scope.emailLimitsLoading = false;
+
+ url = "/emailPremium/getFurtherDomains";
+
+ var data = {page: pageNumber};
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.listWebSiteStatus === 1) {
+
+ $scope.WebSitesList = JSON.parse(response.data.data);
+ $scope.listFail = true;
+ }
+ else
+ {
+ $scope.listFail = false;
+ $scope.errorMessage = response.data.error_message;
+
+ }
+ }
+ function cantLoadInitialData(response) {
+ $scope.emailLimitsLoading = true;
+ $scope.listFail = false;
+ }
+
+
+ };
+ $scope.getFurtherWebsitesFromDB(1);
+
+ $scope.enableDisableEmailLimits = function (operationVal, domainName) {
+
+ $scope.emailLimitsLoading = false;
+
+
+ url = "/emailPremium/enableDisableEmailLimits";
+
+ var data = {
+ operationVal: operationVal,
+ domainName: domainName
+ };
+
+ var config = {
+ headers : {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ $http.post(url, data,config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.emailLimitsLoading = true;
+
+ if (response.data.status === 1) {
+
+ $timeout(function() { $window.location.reload(); }, 3000);
+ }
+ else
+ {
+ $timeout(function() { $window.location.reload(); }, 3000);
+ }
+ }
+ function cantLoadInitialData(response) {
+ $timeout(function() { $window.location.reload(); }, 3000);
+ }
+ }
+});
+
+/* Java script code for email domain page */
\ No newline at end of file
diff --git a/static/emailPremium/settings-gears.png b/static/emailPremium/settings-gears.png
new file mode 100644
index 000000000..34a6f5b0a
Binary files /dev/null and b/static/emailPremium/settings-gears.png differ
diff --git a/static/emailPremium/vpsON.png b/static/emailPremium/vpsON.png
new file mode 100644
index 000000000..14611deab
Binary files /dev/null and b/static/emailPremium/vpsON.png differ
diff --git a/static/emailPremium/vpsOff.png b/static/emailPremium/vpsOff.png
new file mode 100644
index 000000000..e511e68de
Binary files /dev/null and b/static/emailPremium/vpsOff.png differ
diff --git a/static/mailServer/settings-gears.png b/static/mailServer/settings-gears.png
new file mode 100644
index 000000000..34a6f5b0a
Binary files /dev/null and b/static/mailServer/settings-gears.png differ
diff --git a/static/mailServer/vpsON.png b/static/mailServer/vpsON.png
new file mode 100644
index 000000000..14611deab
Binary files /dev/null and b/static/mailServer/vpsON.png differ
diff --git a/static/mailServer/vpsOff.png b/static/mailServer/vpsOff.png
new file mode 100644
index 000000000..e511e68de
Binary files /dev/null and b/static/mailServer/vpsOff.png differ
diff --git a/tuning/__init__.pyc b/tuning/__init__.pyc
index 4d8b43840..4d15ebb46 100644
Binary files a/tuning/__init__.pyc and b/tuning/__init__.pyc differ
diff --git a/tuning/admin.pyc b/tuning/admin.pyc
index 6f8b7d940..f8978efb6 100644
Binary files a/tuning/admin.pyc and b/tuning/admin.pyc differ
diff --git a/tuning/models.pyc b/tuning/models.pyc
index ac6770294..e88347193 100644
Binary files a/tuning/models.pyc and b/tuning/models.pyc differ
diff --git a/userManagment/__init__.pyc b/userManagment/__init__.pyc
index 932555a1f..5567b8f6a 100644
Binary files a/userManagment/__init__.pyc and b/userManagment/__init__.pyc differ
diff --git a/userManagment/admin.pyc b/userManagment/admin.pyc
index 0f08cf20c..a7b5d4f7a 100644
Binary files a/userManagment/admin.pyc and b/userManagment/admin.pyc differ
diff --git a/userManagment/models.pyc b/userManagment/models.pyc
index b8e025709..484042ae9 100644
Binary files a/userManagment/models.pyc and b/userManagment/models.pyc differ
diff --git a/websiteFunctions/__init__.pyc b/websiteFunctions/__init__.pyc
index 6cdcdddf3..a4774f244 100644
Binary files a/websiteFunctions/__init__.pyc and b/websiteFunctions/__init__.pyc differ
diff --git a/websiteFunctions/admin.pyc b/websiteFunctions/admin.pyc
index a7f1d7fa0..3685ce5ea 100644
Binary files a/websiteFunctions/admin.pyc and b/websiteFunctions/admin.pyc differ
diff --git a/websiteFunctions/models.pyc b/websiteFunctions/models.pyc
index adb24a2bb..a6c2b4124 100644
Binary files a/websiteFunctions/models.pyc and b/websiteFunctions/models.pyc differ