postfix_access_policy_delegation protocol
@@ -58,6 +58,7 @@ INSTALLED_APPS = [
|
||||
'manageSSL',
|
||||
'api',
|
||||
'filemanager',
|
||||
'emailPremium'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
||||
@@ -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')),
|
||||
]
|
||||
|
||||
BIN
api/__init__.pyc
BIN
api/admin.pyc
BIN
api/models.pyc
BIN
backup/admin.pyc
@@ -464,7 +464,6 @@
|
||||
<a href="#" title="{% trans 'Tuning' %}">
|
||||
<i class="glyph-icon icon-linecons-fire"></i>
|
||||
<span>{% trans "Tuning" %}</span>
|
||||
<span class="bs-label badge-yellow">{% trans "NEW" %}</span>
|
||||
</a>
|
||||
<div class="sidebar-submenu">
|
||||
|
||||
@@ -549,6 +548,21 @@
|
||||
</div><!-- .sidebar-submenu -->
|
||||
</li>
|
||||
|
||||
<li id="normalUserE">
|
||||
<a href="#" title="{% trans 'Mail Settings' %}">
|
||||
<i class="glyph-icon icon-linecons-fire"></i>
|
||||
<span>{% trans "Mail Settings" %}</span>
|
||||
<span class="bs-label badge-yellow">{% trans "NEW" %}</span>
|
||||
</a>
|
||||
<div class="sidebar-submenu">
|
||||
|
||||
<ul>
|
||||
<li><a href="{% url 'listDomains' %}" title="{% trans 'Email Limits' %}"><span>{% trans "Email Limits" %}</span></a></li>
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
</li>
|
||||
|
||||
|
||||
</ul><!-- #sidebar-menu -->
|
||||
|
||||
@@ -586,6 +600,7 @@
|
||||
<script src="{% static 'databases/databases.js' %}"></script>
|
||||
<script src="{% static 'mailServer/mailServer.js' %}"></script>
|
||||
<script src="{% static 'serverLogs/serverLogs.js' %}"></script>
|
||||
<script src="{% static 'emailPremium/emailPremium.js' %}"></script>
|
||||
|
||||
<!-- PieGage charts -->
|
||||
|
||||
|
||||
BIN
dns/__init__.pyc
BIN
dns/admin.pyc
BIN
dns/models.pyc
0
emailPremium/__init__.py
Normal file
BIN
emailPremium/__init__.pyc
Normal file
6
emailPremium/admin.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
BIN
emailPremium/admin.pyc
Normal file
8
emailPremium/apps.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class EmailpremiumConfig(AppConfig):
|
||||
name = 'emailPremium'
|
||||
0
emailPremium/migrations/__init__.py
Normal file
29
emailPremium/models.py
Normal file
@@ -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)
|
||||
|
||||
BIN
emailPremium/models.pyc
Normal file
673
emailPremium/static/emailPremium/emailPremium.js
Normal file
@@ -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 */
|
||||
BIN
emailPremium/static/emailPremium/settings-gears.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
emailPremium/static/emailPremium/vpsON.png
Normal file
|
After Width: | Height: | Size: 757 B |
BIN
emailPremium/static/emailPremium/vpsOff.png
Normal file
|
After Width: | Height: | Size: 667 B |
221
emailPremium/templates/emailPremium/emailLimits.html
Normal file
@@ -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 %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div ng-controller="emailDomainPage" class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2 ><span id="domainNamePage">{{ domain }}</span></h2>
|
||||
<p>{% trans "View and change email limits for a domain name." %}</p>
|
||||
</div>
|
||||
|
||||
{% if not error %}
|
||||
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
|
||||
|
||||
<h3 class="content-box-header bg-blue">
|
||||
{% trans "Domain Resource Usage" %} <img ng-hide="emailLimitsLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Domain</th>
|
||||
<th>Emails Accounts</th>
|
||||
<th>Monthly Limit</th>
|
||||
<th>Monthly Used</th>
|
||||
<th>Limit Status</th>
|
||||
<th>Operations</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td><code>{{ domain }}</code></td>
|
||||
<td><code>{{ emailAccounts }}</code></td>
|
||||
<td><code>{{ monthlyLimit }}</code></td>
|
||||
<td><code>{{ monthlyUsed }}</code></td>
|
||||
<td>
|
||||
<img style="margin-right: 4%;" ng-show="{{ limitsOn }}" title="{% trans 'Limits are being Applied!' %}" src="{% static 'mailServer/vpsON.png' %}">
|
||||
<button ng-click="enableDisableEmailLimits(0, '{{ domain }}')" ng-show="{{ limitsOn }}" class="btn ra-100 btn-danger">{% trans 'Disable' %}</button>
|
||||
<img style="margin-right: 4%;" ng-show="{{ limitsOff }}" title="{% trans 'Limits are not being applied!' %}" src="{% static 'mailServer/vpsOff.png' %}">
|
||||
<button ng-click="enableDisableEmailLimits(1, '{{ domain }}')" ng-show="{{ limitsOff }}" class="btn ra-100 btn-success">{% trans 'Enable' %}</button>
|
||||
</td>
|
||||
<td>
|
||||
<a ng-click="showLimitsForm()"><button class="btn ra-100 btn-blue-alt">{% trans 'Edit' %}</button></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div ng-hide="changeLimitsForm" class="col-md-12">
|
||||
<form name="websiteCreationForm" action="/" class="form-horizontal bordered-row">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Monthly Limit" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="dom" type="number" class="form-control" ng-model="monthlyLimit" required>
|
||||
</div>
|
||||
<div style="margin-bottom: 1%;" class=" col-sm-1">
|
||||
<a title="{% trans 'Cancel' %}" ng-click="hideLimitsForm()" href=""><img src="/static/images/close-32.png"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="changeDomainEmailLimits('{{ domain }}')" class="btn btn-primary btn-lg btn-block">{% trans "Change Limits" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<div ng-hide="changeLimitsFail" class="alert alert-danger">
|
||||
<p>{% trans "Can not change limits. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="changeLimitsSuccess" class="alert alert-success">
|
||||
<p>{% trans "Limits successfully changed, refreshing in 3 seconds." %}</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>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
|
||||
|
||||
<h3 class="content-box-header bg-blue">
|
||||
{% trans "Email Resource Usage" %} <img ng-hide="emailLimitsLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row">
|
||||
<div style="margin-bottom: 1%" class="col-md-12">
|
||||
<input type="text" ng-model="emailSearch" placeholder="{% trans 'Search Emails..' %}" class="form-control autocomplete-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Email</th>
|
||||
<th>Monthly Limit</th>
|
||||
<th>Monthly Used</th>
|
||||
<th>Hourly Limit</th>
|
||||
<th>Hourly Used</th>
|
||||
<th style="width: 15%;">Limit Status</th>
|
||||
<th>Operations</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr ng-repeat="email in emailList | filter:emailSearch">
|
||||
<td ><code ng-bind="email.email"></code></td>
|
||||
<td><code ng-bind="email.monthlyLimit"></code></td>
|
||||
<td><code ng-bind="email.monthlyUsed"></code></td>
|
||||
<td><code ng-bind="email.hourlyLimit"></code></td>
|
||||
<td><code ng-bind="email.hourlyUsed"></code></td>
|
||||
<td>
|
||||
<img style="margin-right: 4%;" ng-show="email.status==1" title="{% trans 'Limits are being Applied!' %}" src="{% static 'mailServer/vpsON.png' %}">
|
||||
<button ng-click="enableDisableIndividualEmailLimits(0, email.email)" ng-show="email.status==1" class="btn ra-100 btn-danger">{% trans 'Disable' %}</button>
|
||||
<img style="margin-right: 4%;" ng-show="email.status==0" title="{% trans 'Limits are not being applied!' %}" src="{% static 'mailServer/vpsOff.png' %}">
|
||||
<button ng-click="enableDisableIndividualEmailLimits(1, email.email)" ng-show="email.status==0" class="btn ra-100 btn-success">{% trans 'Enable' %}</button>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/emailPremium/{$ email.email $}"><button class="btn ra-100 btn-blue-alt">{% trans 'Manage' %}</button></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div ng-hide="listFail" class="alert alert-danger">
|
||||
<p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4 col-sm-offset-8">
|
||||
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
|
||||
|
||||
{% for items in pagination %}
|
||||
|
||||
<li ng-click="getFurtherEmailsFromDB({{ forloop.counter }})" id="webPages"><a href="">{{ forloop.counter }}</a></li>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<p>{{ domain }}</p>
|
||||
</div>
|
||||
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
228
emailPremium/templates/emailPremium/emailPage.html
Normal file
@@ -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 %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div ng-controller="emailPage" class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2 ><span id="emailAddress">{{ emailAddress }}</span></h2>
|
||||
<p>{% trans "View and change limits for an Email Address." %}</p>
|
||||
</div>
|
||||
|
||||
{% if not error %}
|
||||
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
|
||||
|
||||
<h3 class="content-box-header bg-blue">
|
||||
{% trans "Email Resource Usage" %} <img ng-hide="emailLimitsLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Email</th>
|
||||
<th>Monthly Limit</th>
|
||||
<th>Monthly Used</th>
|
||||
<th>Hourly Limit</th>
|
||||
<th>Hourly Used</th>
|
||||
<th style="width: 15%;">Limit Status</th>
|
||||
<th style="width: 15%;">Logs</th>
|
||||
<th>Operations</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td ><code ng-model="email">{{ emailAddress }}</code></td>
|
||||
<td><code>{$ monthlyLimit $}</code></td>
|
||||
<td><code>{$ monthlyUsed $}</code></td>
|
||||
<td><code>{$ hourlyLimit $}</code></td>
|
||||
<td><code>{$ hourlyUsed $}</code></td>
|
||||
<td>
|
||||
<img style="margin-right: 4%;" ng-hide="limitsOn" title="{% trans 'Limits are being Applied!' %}" src="{% static 'mailServer/vpsON.png' %}">
|
||||
<button ng-click="enableDisableIndividualEmailLimits(0, '{{ emailAddress }}')" ng-hide="limitsOn" class="btn ra-100 btn-danger">{% trans 'Disable' %}</button>
|
||||
<img style="margin-right: 4%;" ng-hide="limitsOff" title="{% trans 'Limits are not being applied!' %}" src="{% static 'mailServer/vpsOff.png' %}">
|
||||
<button ng-click="enableDisableIndividualEmailLimits(1, '{{ emailAddress }}')" ng-hide="limitsOff" class="btn ra-100 btn-success">{% trans 'Enable' %}</button>
|
||||
</td>
|
||||
<td>
|
||||
<img style="margin-right: 4%;" ng-hide="loggingOn" title="{% trans 'Logging in ON!' %}" src="{% static 'mailServer/vpsON.png' %}">
|
||||
<button ng-click="enableDisableIndividualEmailLogs(0, '{{ emailAddress }}')" ng-hide="loggingOn" class="btn ra-100 btn-danger">{% trans 'Disable' %}</button>
|
||||
<img style="margin-right: 4%;" ng-hide="loggingOff" title="{% trans 'Logging is Off' %}" src="{% static 'mailServer/vpsOff.png' %}">
|
||||
<button ng-click="enableDisableIndividualEmailLogs(1, '{{ emailAddress }}')" ng-hide="loggingOff" class="btn ra-100 btn-success">{% trans 'Enable' %}</button>
|
||||
</td>
|
||||
<td>
|
||||
<button ng-click="showLimitsForm()" class="btn ra-100 btn-blue-alt">{% trans 'Edit' %}</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div ng-hide="changeLimitsForm" class="col-md-12">
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Monthly Limit" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="dom" type="number" class="form-control" ng-model="monthlyLimitForm" required>
|
||||
</div>
|
||||
<div style="margin-bottom: 1%;" class=" col-sm-1">
|
||||
<a title="{% trans 'Cancel' %}" ng-click="hideLimitsForm()" href=""><img src="/static/images/close-32.png"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Hourly Limit" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="dom" type="number" class="form-control" ng-model="hourlyLimitForm" required>
|
||||
</div>
|
||||
<div style="margin-bottom: 1%;" class=" col-sm-1">
|
||||
<a title="{% trans 'Cancel' %}" ng-click="hideLimitsForm()" href=""></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="changeDomainEmailLimitsIndividual()" class="btn btn-primary btn-lg btn-block">{% trans "Change Limits" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<div ng-hide="changeLimitsFail" class="alert alert-danger">
|
||||
<p>{% trans "Can not change limits. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="changeLimitsSuccess" class="alert alert-success">
|
||||
<p>{% trans "Limits successfully changed." %}</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>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
|
||||
|
||||
<h3 class="content-box-header bg-blue">
|
||||
{% trans "Email Logs" %} <img ng-hide="emailLimitsLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row">
|
||||
<div style="margin-bottom: 1%" class="col-md-10">
|
||||
<input type="text" ng-model="logSearch" placeholder="{% trans 'Search Emails Logs..' %}" class="form-control autocomplete-input">
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 1%" class="col-md-2">
|
||||
<button ng-click="flushLogs('{{ emailAddress }}')" ng-hide="loggingOn" class="btn ra-100 btn-danger">{% trans 'Flush Logs' %}</button>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Source</th>
|
||||
<th>Destination</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr ng-repeat="log in logs | filter:logSearch">
|
||||
<td ><code ng-bind="log.id"></code></td>
|
||||
<td><code ng-bind="log.source"></code></td>
|
||||
<td><code ng-bind="log.destination"></code></td>
|
||||
<td><code ng-bind="log.time"></code></td>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div ng-hide="listFail" class="alert alert-danger">
|
||||
<p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4 col-sm-offset-8">
|
||||
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
|
||||
{% for items in pagination %}
|
||||
|
||||
<li ng-click="getLogEntries({{ forloop.counter }})" id="webPages"><a href="">{{ forloop.counter }}</a></li>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<p>{{ domain }}</p>
|
||||
</div>
|
||||
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
90
emailPremium/templates/emailPremium/listDomains.html
Normal file
@@ -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 %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2 id="domainNamePage">{% trans "List Domains" %}</h2>
|
||||
<p>{% trans "On this page you manage emails limits for Domains/Email Addresses" %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-controller="listDomains" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Domains" %} <img ng-hide="emailLimitsLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Domain</th>
|
||||
<th>Emails Accounts</th>
|
||||
<th>Monthly Limit</th>
|
||||
<th>Monthly Used</th>
|
||||
<th>Limit Status</th>
|
||||
<th>Operations</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr ng-repeat="web in WebSitesList track by $index">
|
||||
<td ><code ng-bind="web.domain"></code></td>
|
||||
<td><code ng-bind="web.emails"></code></td>
|
||||
<td><code ng-bind="web.monthlyLimit"></code></td>
|
||||
<td><code ng-bind="web.monthlyUsed"></code></td>
|
||||
<td>
|
||||
<img style="margin-right: 4%;" ng-show="web.status==1" title="{% trans 'Limits are being Applied!' %}" src="{% static 'mailServer/vpsON.png' %}">
|
||||
<button ng-click="enableDisableEmailLimits(0, web.domain)" ng-show="web.status==1" class="btn ra-100 btn-danger">{% trans 'Disable' %}</button>
|
||||
<img style="margin-right: 4%;" ng-show="web.status==0" title="{% trans 'Limits are not being applied!' %}" src="{% static 'mailServer/vpsOff.png' %}">
|
||||
<button ng-click="enableDisableEmailLimits(1, web.domain)" ng-show="web.status==0" class="btn ra-100 btn-success">{% trans 'Enable' %}</button>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/emailPremium/{$ web.domain $}"><button class="btn ra-100 btn-blue-alt">{% trans 'Manage' %}</button></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div ng-hide="listFail" class="alert alert-danger">
|
||||
<p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4 col-sm-offset-8">
|
||||
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
|
||||
|
||||
{% for items in pagination %}
|
||||
|
||||
<li ng-click="getFurtherWebsitesFromDB({{ forloop.counter }})" id="webPages"><a href="">{{ forloop.counter }}</a></li>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
6
emailPremium/tests.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
28
emailPremium/urls.py
Normal file
@@ -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<domain>([\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<emailAddress>\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'),
|
||||
|
||||
|
||||
|
||||
|
||||
]
|
||||
575
emailPremium/views.py
Normal file
@@ -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('<li><a href="\#"></a></li>')
|
||||
else:
|
||||
pages = ceil(pages)
|
||||
finalPages = int(pages) + 1
|
||||
|
||||
for i in range(1, finalPages):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
|
||||
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('<li><a href="\#"></a></li>')
|
||||
else:
|
||||
pages = ceil(pages)
|
||||
finalPages = int(pages) + 1
|
||||
|
||||
for i in range(1, finalPages):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
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('<li><a href="\#"></a></li>')
|
||||
else:
|
||||
pages = ceil(pages)
|
||||
finalPages = int(pages) + 1
|
||||
|
||||
for i in range(1, finalPages):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
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)
|
||||
200
firewall/templates/firewall/spamassassin.html
Normal file
@@ -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 %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "SpamAssassin Configurations!" %} </h2>
|
||||
<p>{% trans "On this page you can configure SpamAssassin settings." %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-controller="modSec" class="example-box-wrapper">
|
||||
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
|
||||
<h3 class="content-box-header bg-blue">
|
||||
{% trans "SpamAssassin" %} <img ng-hide="modsecLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row">
|
||||
|
||||
{% if modSecInstalled == 0 %}
|
||||
|
||||
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
|
||||
<h3>{% trans "ModSecurity is not installed " %}
|
||||
<button ng-click="installModSec()" class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>{% trans "Install Now." %}</span>
|
||||
<i class="glyph-icon icon-arrow-right"></i>
|
||||
</button></h3>
|
||||
</div>
|
||||
|
||||
<!------ ModeSec Install Log box ----------------->
|
||||
|
||||
<div ng-hide="modSecNotifyBox" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
<div ng-hide="failedToStartInallation" class="alert alert-danger">
|
||||
<p>{% trans "Failed to start installation, Error message: " %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect. Please refresh this page." %} </p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Installation failed." %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="modSecSuccessfullyInstalled" class="alert alert-success">
|
||||
<p>{% trans "ModSecurity successfully installed, refreshing page in 3 seconds.." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="modeSecInstallBox" class="col-md-12">
|
||||
|
||||
<form action="/" id="" class="form-horizontal bordered-row">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 text-center">
|
||||
<h3><img src="{% static 'firewall/icons/firewall.png' %}"> {% trans "Winter is coming, but so is ModSecurity." %} <img ng-hide="modsecLoading" src="/static/images/loading.gif"></h3>
|
||||
</div>
|
||||
<div style="margin-top: 2%;" class="col-sm-12">
|
||||
<textarea ng-model="requestData" rows="15" class="form-control">{{ requestData }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<!----- ModeSec Install Log box ----------------->
|
||||
{% else %}
|
||||
|
||||
<div style="padding: 2%" class="col-md-12">
|
||||
<form action="/" id="createPackages" class="form-horizontal bordered-row">
|
||||
|
||||
<div ng-hide="phpDetailsBox" class="form-group">
|
||||
<label class="col-sm-4 control-label">ModSecurity Status</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" id="modsecurity_status" data-toggle="toggle">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="phpDetailsBox" class="form-group">
|
||||
<label class="col-sm-4 control-label">SecAuditEngine</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" id="SecAuditEngine" data-toggle="toggle">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="phpDetailsBox" class="form-group">
|
||||
<label class="col-sm-4 control-label">SecRuleEngine</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" id="SecRuleEngine" data-toggle="toggle">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">SecDebugLogLevel</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="selector" style="width: 79px;"><span style="width: 57px; -moz-user-select: none;">{$ SecDebugLogLevel $}</span><select ng-model="SecDebugLogLevel" class="custom-select">
|
||||
<option>1</option>
|
||||
<option>2</option>
|
||||
<option>3</option>
|
||||
<option>4</option>
|
||||
<option>5</option>
|
||||
<option>6</option>
|
||||
<option>7</option>
|
||||
<option>8</option>
|
||||
<option>9</option>
|
||||
</select><i class="glyph-icon icon-caret-down"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">SecAuditLogParts</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="selector" style="width: 79px;"><span style="width: 57px; -moz-user-select: none;">{$ SecAuditLogParts $}</span><select ng-model="SecAuditLogParts" class="custom-select">
|
||||
<option>A</option>
|
||||
<option>AB</option>
|
||||
<option>ABI</option>
|
||||
<option>ABIJ</option>
|
||||
<option>ABIJD</option>
|
||||
<option>ABIJDE</option>
|
||||
<option>ABIJDEF</option>
|
||||
<option>ABIJDEFH</option>
|
||||
<option>ABIJDEFHZ</option>
|
||||
</select><i class="glyph-icon icon-caret-down"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">SecAuditLogRelevantStatus</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="SecAuditLogRelevantStatus" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">SecAuditLogType</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="SecAuditLogType" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="saveModSecConfigurations()" class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
|
||||
<div ng-hide="failedToSave" class="alert alert-danger">
|
||||
<p>{% trans "Failed to save ModSecurity configurations. Error message: " %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="successfullySaved" class="alert alert-success">
|
||||
<p>{% trans "ModSecurity configurations successfully saved." %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect. Please refresh this page." %} </p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -40,5 +40,10 @@ urlpatterns = [
|
||||
url(r'^enableDisableRuleFile', views.enableDisableRuleFile, name='enableDisableRuleFile'),
|
||||
|
||||
|
||||
## SpamAssassin
|
||||
|
||||
url(r'^spamAssassin', views.spamAssassin, name='spamAssassin'),
|
||||
|
||||
|
||||
|
||||
]
|
||||
@@ -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):
|
||||
|
||||
BIN
ftp/__init__.pyc
BIN
ftp/admin.pyc
BIN
ftp/models.pyc
@@ -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()
|
||||
|
||||
@@ -33,4 +33,5 @@ urlpatterns = [
|
||||
url(r'^installOpenDKIM', views.installOpenDKIM, name='installOpenDKIM'),
|
||||
url(r'^installStatusOpenDKIM', views.installStatusOpenDKIM, name='installStatusOpenDKIM'),
|
||||
|
||||
|
||||
]
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<div class="col-sm-12">
|
||||
<input type="text" ng-model="extSearch" placeholder="{% trans 'Search Extensions..' %}" class="form-control autocomplete-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="availableExtensions" class="form-group">
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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()
|
||||
0
postfixSenderPolicy/__init__.py
Normal file
BIN
postfixSenderPolicy/__pycache__/rawFileParser.cpython-36.pyc
Executable file
108
postfixSenderPolicy/accept_traffic.py
Executable file
@@ -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))
|
||||
198
postfixSenderPolicy/cacheManager.py
Executable file
@@ -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))
|
||||
|
||||
48
postfixSenderPolicy/client.py
Executable file
@@ -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()
|
||||
12
postfixSenderPolicy/cpecs.service
Executable file
@@ -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
|
||||
55
postfixSenderPolicy/policyCTRL.py
Executable file
@@ -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()
|
||||
33
postfixSenderPolicy/policyConstraint.py
Normal file
@@ -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
|
||||
59
postfixSenderPolicy/startServer.py
Executable file
@@ -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()
|
||||
|
||||
199
static/emailPremium/emailPremium.js
Normal file
@@ -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 */
|
||||
BIN
static/emailPremium/settings-gears.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
static/emailPremium/vpsON.png
Normal file
|
After Width: | Height: | Size: 757 B |
BIN
static/emailPremium/vpsOff.png
Normal file
|
After Width: | Height: | Size: 667 B |
BIN
static/mailServer/settings-gears.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
static/mailServer/vpsON.png
Normal file
|
After Width: | Height: | Size: 757 B |
BIN
static/mailServer/vpsOff.png
Normal file
|
After Width: | Height: | Size: 667 B |