This commit is contained in:
Hassan Hashmi
2022-07-21 17:42:48 +05:00
parent 4cdedc7ad5
commit 7c40b677d4
10 changed files with 2001 additions and 82 deletions

View File

@@ -74,7 +74,7 @@ class secMiddleware:
if request.build_absolute_uri().find('api/remoteTransfer') > -1 or request.build_absolute_uri().find('api/verifyConn') > -1 or request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1: if request.build_absolute_uri().find('api/remoteTransfer') > -1 or request.build_absolute_uri().find('api/verifyConn') > -1 or request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1:
continue continue
if key == 'key' or key == 'cert' or key == 'recordContentAAAA' or key == 'backupDestinations' or key == 'ports' \ if key == 'CLAMAV_VIRUS' or key == "Rspamdserver" or key == 'smtpd_milters' or key == 'non_smtpd_milters' or key == 'key' or key == 'cert' or key == 'recordContentAAAA' or key == 'backupDestinations' or key == 'ports' \
or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \ or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \
or key == 'emailMessage' or key == 'configData' or key == 'rewriteRules' \ or key == 'emailMessage' or key == 'configData' or key == 'rewriteRules' \
or key == 'modSecRules' or key == 'recordContentTXT' or key == 'SecAuditLogRelevantStatus' \ or key == 'modSecRules' or key == 'recordContentTXT' or key == 'SecAuditLogRelevantStatus' \

View File

@@ -24,7 +24,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f' SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False DEBUG = True
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
@@ -111,8 +111,8 @@ DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'NAME': 'cyberpanel', 'NAME': 'cyberpanel',
'USER': 'cyberpanel', 'USER': 'root',
'PASSWORD': 'Bz9gF7Hr7X4RtD', 'PASSWORD': 'VY7ZbcQREu6mSC',
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': '' 'PORT': ''
}, },
@@ -120,7 +120,7 @@ DATABASES = {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'NAME': 'mysql', 'NAME': 'mysql',
'USER': 'root', 'USER': 'root',
'PASSWORD': 'sXm5VlRaAsXkDd', 'PASSWORD': 'VY7ZbcQREu6mSC',
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': '', 'PORT': '',
}, },

View File

@@ -1034,6 +1034,9 @@
<li><a href="{% url 'MailScanner' %}" <li><a href="{% url 'MailScanner' %}"
title="{% trans 'MailScanner' %}"><span>{% trans "MailScanner" %}</span></a> title="{% trans 'MailScanner' %}"><span>{% trans "MailScanner" %}</span></a>
</li> </li>
<li><a href="{% url 'Rspamd' %}"
title="{% trans 'Rspamd' %}"><span>{% trans "Rspamd" %}</span></a>
</li>
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->

View File

@@ -678,7 +678,7 @@ app.controller('SpamAssassin', function ($scope, $http, $timeout, $window) {
$scope.SpamAssassinLoading = true; $scope.SpamAssassinLoading = true;
$scope.failedToStartInallation = true; $scope.failedToStartInallation = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.SpamAssassinSuccessfullyInstalled = true; $scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true; $scope.installationFailed = true;
@@ -955,6 +955,654 @@ app.controller('SpamAssassin', function ($scope, $http, $timeout, $window) {
/* Java script code for SpamAssassin */ /* Java script code for SpamAssassin */
/* Rspamd start */
app.controller('Rspamd', function ($scope, $http, $timeout, $window) {
$scope.RspamdNotifyBox = true;
$scope.RspamdInstallBox = true;
$scope.RspamdLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
$scope.failedToSave = true;
$scope.successfullySaved = true;
$scope.ActionValue = true;
$scope.installedrspamd = false;
$scope.uninstalldiv = true;
$scope.uninstallRspamdNotifyBox = true;
$scope.uninstallRspamdInstallBox = true;
$scope.uninstallbutton = true;
$scope.installRspamd = function () {
$scope.RspamdNotifyBox = true;
$scope.RspamdInstallBox = true;
$scope.RspamdLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
var url = "/emailPremium/installRspamd";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.status === 1) {
$scope.RspamdNotifyBox = true;
$scope.RspamdInstallBox = false;
$scope.RspamdLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
getRequestStatus();
} else {
$scope.errorMessage = response.data.error_message;
$scope.RspamdNotifyBox = false;
$scope.RspamdInstallBox = true;
$scope.RspamdLoading = true;
$scope.failedToStartInallation = false;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
}
}
function cantLoadInitialDatas(response) {
$scope.RspamdNotifyBox = false;
$scope.RspamdInstallBox = false;
$scope.RspamdLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = false;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
}
};
function getRequestStatus() {
$scope.RspamdNotifyBox = true;
$scope.RspamdInstallBox = false;
$scope.RspamdLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
var url = "/emailPremium/installStatusRspamd";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.abort === 0) {
$scope.RspamdNotifyBox = true;
$scope.RspamdInstallBox = false;
$scope.RspamdLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
$scope.requestData = response.data.requestStatus;
$timeout(getRequestStatus, 1000);
} else {
// Notifications
$timeout.cancel();
$scope.RspamdNotifyBox = false;
$scope.RspamdInstallBox = false;
$scope.RspamdLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.requestData = response.data.requestStatus;
if (response.data.installed === 0) {
$scope.installationFailed = false;
$scope.errorMessage = response.data.error_message;
} else {
$scope.RspamdSuccessfullyInstalled = false;
$timeout(function () {
$window.location.reload();
}, 3000);
}
}
}
function cantLoadInitialDatas(response) {
$scope.RspamdNotifyBox = false;
$scope.RspamdInstallBox = false;
$scope.RspamdLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = false;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
}
}
var antivirus_status = false;
var scan_mime_parts = false;
var log_clean = false;
$('#antivirus_status').change(function () {
antivirus_status = $(this).prop('checked');
});
$('#scan_mime_parts').change(function () {
scan_mime_parts = $(this).prop('checked');
});
$('#log_clean').change(function () {
log_clean = $(this).prop('checked');
});
fetchRspamdSettings();
function fetchRspamdSettings() {
$scope.RspamdLoading = false;
var url = "/emailPremium/fetchRspamdSettings";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.RspamdLoading = true;
$scope.ActionValue = false;
if (response.data.fetchStatus === 1) {
if (response.data.installed === 1) {
$scope.uninstallbutton = false;
if (response.data.enabled === true) {
$('#antivirus_status').bootstrapToggle('on');
} else if (response.data.enabled === false) {
$('#antivirus_status').bootstrapToggle('off');
}
if (response.data.scan_mime_parts === true) {
$('#scan_mime_parts').bootstrapToggle('on');
} else if (response.data.scan_mime_parts === false) {
$('#scan_mime_parts').bootstrapToggle('off');
}
if (response.data.log_clean === true) {
$('#log_clean').bootstrapToggle('on');
} else if (response.data.log_clean === false) {
$('#log_clean').bootstrapToggle('off');
}
$scope.max_size = response.data.max_Size;
$scope.server = response.data.Server;
$scope.CLAMAV_VIRUS = response.data.CLAMAV_VIRUS;
$('#selctedaction').text(response.data.action);
$scope.smtpd_milters = response.data.smtpd_milters;
$scope.non_smtpd_milters = response.data.non_smtpd_milters;
$scope.read_servers = response.data.read_servers;
$scope.write_servers = response.data.write_servers;
// $scope.required_score = response.data.required_score;
//
}
}
}
function cantLoadInitialDatas(response) {
$scope.RspamdLoading = true;
}
}
$scope.saveRspamdConfigurations = function () {
$scope.failedToSave = true;
$scope.successfullySaved = true;
$scope.RspamdLoading = false;
$scope.couldNotConnect = true;
url = "/emailPremium/saveRspamdConfigurations";
var data = {
status: antivirus_status,
scan_mime_parts: scan_mime_parts,
log_clean: log_clean,
action_rspamd: $scope.action_rspamd,
max_size: $scope.max_size,
Rspamdserver: $scope.server,
CLAMAV_VIRUS: $scope.CLAMAV_VIRUS,
};
// console.log(data)
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
if ($scope.action_rspamd == undefined) {
alert('Please Select Action')
$scope.RspamdLoading = true;
} else {
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
}
function ListInitialDatas(response) {
if (response.data.saveStatus === 1) {
$scope.failedToSave = true;
$scope.successfullySaved = false;
$scope.RspamdLoading = true;
$scope.couldNotConnect = true;
location.reload();
} else {
$scope.errorMessage = response.data.error_message;
$scope.failedToSave = false;
$scope.successfullySaved = true;
$scope.RspamdLoading = true;
$scope.couldNotConnect = true;
}
}
function cantLoadInitialDatas(response) {
$scope.failedToSave = true;
$scope.successfullySaved = true;
$scope.RspamdLoading = true;
$scope.couldNotConnect = false;
}
};
///postfix;
$scope.postfixfailedToSave = true;
$scope.postfixsuccessfullySaved = true;
$scope.postfixcouldNotConnect = true;
$scope.postfixLoading = true;
$scope.savepostfixConfigurations = function () {
$scope.postfixLoading = false;
url = "/emailPremium/savepostfixConfigurations";
var data = {
smtpd_milters: $scope.smtpd_milters,
non_smtpd_milters: $scope.non_smtpd_milters,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.saveStatus === 1) {
$scope.postfixfailedToSave = true;
$scope.postfixsuccessfullySaved = false;
$scope.postfixLoading = true;
$scope.postfixcouldNotConnect = true;
location.reload();
} else {
$scope.errorMessage = response.data.error_message;
$scope.postfixfailedToSave = false;
$scope.postfixsuccessfullySaved = true;
$scope.postfixLoading = true;
$scope.postfixcouldNotConnect = true;
}
}
function cantLoadInitialDatas(response) {
$scope.postfixfailedToSave = true;
$scope.postfixsuccessfullySaved = true;
$scope.postfixLoading = true;
$scope.postfixcouldNotConnect = false;
}
};
////Redis
$scope.RedisfailedToSave = true;
$scope.RedissuccessfullySaved = true;
$scope.RediscouldNotConnect = true;
$scope.RedisLoading = true;
$scope.saveRedisConfigurations = function () {
$scope.RedisLoading = false;
url = "/emailPremium/saveRedisConfigurations";
var data = {
write_servers: $scope.write_servers,
read_servers: $scope.read_servers,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.saveStatus === 1) {
$scope.RedisfailedToSave = true;
$scope.RedissuccessfullySaved = false;
$scope.RedisLoading = true;
$scope.RediscouldNotConnect = true;
location.reload();
} else {
$scope.errorMessage = response.data.error_message;
$scope.RedisfailedToSave = false;
$scope.RedissuccessfullySaved = true;
$scope.RedisLoading = true;
$scope.RediscouldNotConnect = true;
}
}
function cantLoadInitialDatas(response) {
$scope.RedisfailedToSave = true;
$scope.RedissuccessfullySaved = true;
$scope.RedisLoading = true;
$scope.RediscouldNotConnect = false;
}
};
////uninstall
$scope.RspamduninstallLoading = true;
$scope.uninstallationProgress = true;
$scope.errorMessageBox = true;
$scope.uninstallsuccess = true;
$scope.couldNotConnect = true;
$scope.unistallRspamd = function () {
$('#UninstallRspamdmodal').modal('hide');
$scope.RspamdLoading = false;
$scope.uninstalldiv = false;
$scope.uninstallbutton = true;
$scope.installedrspamd = true;
var url = "/emailPremium/unistallRspamd";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
console.log(response.data)
if (response.data.status === 1) {
console.log(response.data)
$scope.uninstallRspamdNotifyBox = true;
$scope.uninstallRspamdInstallBox = false;
$scope.RspamdLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
getuninstallRequestStatus();
} else {
$scope.errorMessage = response.data.error_message;
$scope.uninstallRspamdNotifyBox = false;
$scope.uninstallRspamdInstallBox = true;
$scope.RspamdLoading = true;
$scope.failedToStartInallation = false;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
}
}
function cantLoadInitialDatas(response) {
$scope.uninstallRspamdNotifyBox = false;
$scope.uninstallRspamdInstallBox = false;
$scope.RspamdLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = false;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
}
};
function getuninstallRequestStatus() {
$scope.uninstallRspamdNotifyBox = true;
$scope.uninstallRspamdInstallBox = false;
$scope.RspamdLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
var url = "/emailPremium/uninstallStatusRspamd";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.abort === 0) {
$scope.uninstallRspamdNotifyBox = true;
$scope.uninstallRspamdInstallBox = false;
$scope.RspamdLoading = false;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
$scope.requestData = response.data.requestStatus;
$timeout(getuninstallRequestStatus, 1000);
} else {
// Notifications
$timeout.cancel();
$scope.uninstallRspamdNotifyBox = false;
$scope.uninstallRspamdInstallBox = false;
$scope.RspamdLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = true;
$scope.requestData = response.data.requestStatus;
if (response.data.installed === 0) {
$scope.installationFailed = false;
$scope.errorMessage = response.data.error_message;
} else {
$scope.RspamdSuccessfullyInstalled = false;
$timeout(function () {
location.reload();
}, 3000);
}
}
}
function cantLoadInitialDatas(response) {
$scope.uninstallRspamdNotifyBox = false;
$scope.uninstallRspamdInstallBox = false;
$scope.RspamdLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = false;
$scope.RspamdSuccessfullyInstalled = true;
$scope.installationFailed = true;
}
}
// function getUninstallationStatus(){
// $scope.RspamduninstallLoading = false;
// url = "/websites/installWordpressStatus";
//
// var data = {
// statusFile: statusFile
// };
// var config = {
// headers: {
// 'X-CSRFToken': getCookie('csrftoken')
// }
// };
//
//
// $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
//
//
// function ListInitialDatas(response) {
// $scope.RspamduninstallLoading = true;
//
// if (response.data.abort === 1) {
//
// if (response.data.installStatus === 1) {
//
//
// $scope.RspamduninstallLoading = true;
// $scope.uninstallationProgress = false;
// $scope.errorMessageBox = true;
// $scope.uninstallsuccess = false;
// $scope.couldNotConnect = true;
//
//
// $("#installProgress").css("width", "100%");
// $("#installProgressbackup").css("width", "100%");
// $scope.installPercentage = "100";
// $scope.currentStatus = response.data.currentStatus;
// $timeout.cancel();
//
//
// } else {
//
// $scope.RspamduninstallLoading = true;
// $scope.uninstallationProgress = false;
// $scope.errorMessageBox = false;
// $scope.uninstallsuccess = true;
// $scope.couldNotConnect = true;
// $scope.errorMessage = response.data.error_message;
//
// $("#installProgress").css("width", "0%");
// $("#installProgressbackup").css("width", "0%");
// $scope.installPercentage = "0";
// $scope.goBackDisable = false;
//
//
// }
//
// } else {
//
// $("#installProgress").css("width", response.data.uninstallationProgress + "%");
// $("#installProgressbackup").css("width", response.data.uninstallationProgress + "%");
// $scope.installPercentage = response.data.uninstallationProgress;
// $scope.currentStatus = response.data.currentStatus;
// $timeout(getCreationStatus, 1000);
//
// }
//
// }
//
// function cantLoadInitialDatas(response) {
// $('#wordpresshomeloading').hide();
// $scope.RspamduninstallLoading = true;
// $scope.uninstallationProgress = false;
// $scope.errorMessageBox = true;
// $scope.uninstallsuccess = true;
// $scope.couldNotConnect = false;
//
//
// }
// }
});
/* Java script code for Email Policy Server */ /* Java script code for Email Policy Server */
app.controller('policyServer', function ($scope, $http, $timeout, $window) { app.controller('policyServer', function ($scope, $http, $timeout, $window) {

View File

@@ -0,0 +1,409 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Rspamd - 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 "Rspamd Configurations!" %} - <a target="_blank"
href="http://go.cyberpanel.net/SpamAssassin"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "Rspamd Docs" %}</span></a>
</h2>
<p>{% trans "On this page you can configure RSPAMD settings." %}</p>
</div>
<div ng-controller="Rspamd" class="example-box-wrapper">
<div class="panel panel-body">
<div style="width: 100%; margin: 0 auto">
<div class="col-lg-10" style="float: left">
<h3 class="content-box-header">
{% trans "Rspamd" %} <img ng-hide="RspamdLoading" src="/static/images/loading.gif">
</h3>
</div>
<div ng-hide="uninstallbutton" class="col-lg-2" style="float: left">
<button type="button" data-toggle="modal" data-target="#UninstallRspamdmodal"
class="btn btn-danger btn-lg btn-block">{% trans "uninstall." %}</button>
</div>
</div>
{#-------------------------------un install process----------------------------------#}
<div ng-hide="uninstalldiv">
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h4 class="mb-10">{% trans "Uninstalling Rspamd " %}
</h4>
</div>
</div>
<!------ RSPAMD unInstall Log box ----------------->
<div ng-hide="uninstallRspamdNotifyBox" 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 Uninstallation, 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="RspamdSuccessfullyInstalled" class="alert alert-success">
<p>{% trans "RSPAMD successfully Uninstalled, refreshing page in 3 seconds.." %}</p>
</div>
</div>
</div>
<div ng-hide="uninstallRspamdInstallBox" 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 RSPAMD." %}
<img ng-hide="RspamdLoading" 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>
<!----- RSPAMD unInstall Log box ----------------->
<div class="content-box-wrapper">
<div class="row">
{% if checkIfRspamdInstalled == 0 %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h4 class="mb-10">{% trans "Rspamd is not installed " %}
</h4>
<button ng-click="installRspamd()" class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Install Now." %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
</div>
<!------ RSPAMD Install Log box ----------------->
<div ng-hide="RspamdNotifyBox" 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="RspamdSuccessfullyInstalled" class="alert alert-success">
<p>{% trans "RSPAMD successfully installed, refreshing page in 3 seconds.." %}</p>
</div>
</div>
</div>
<div ng-hide="RspamdInstallBox" 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 RSPAMD." %}
<img ng-hide="RspamdLoading" 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>
<!----- RSPAMD Install Log box ----------------->
{% else %}
<div ng-hide="installedrspamd">
<!-----------------------------------------ClamAv--------------------------->
<div style="padding: 2%" class="col-md-12">
<h3 class="content-box-header">
{% trans "ClamAV" %}
</h3>
<form action="/" id="createPackages" class="form-horizontal bordered-row">
<div ng-hide="phpDetailsBox" class="form-group">
<label class="col-sm-4 control-label">Antivirus Status</label>
<div class="col-sm-6">
<input type="checkbox" id="antivirus_status" data-toggle="toggle">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">Action</label>
<div class="col-sm-6">
<select class="form-control" ng-model="action_rspamd">
<option selected="selected">Reject</option>
<option>Unset</option>
</select>
</div>
<div ng-hide="ActionValue" class="col-sm-2">
<strong style="margin-top: 10px; ">Selected</strong>
<strong ng-model="selctedaction" id="selctedaction"></strong>
</div>
</div>
<div ng-hide="phpDetailsBox" class="form-group">
<label class="col-sm-4 control-label">Scan Mime Parts</label>
<div class="col-sm-6">
<input type="checkbox" id="scan_mime_parts" data-toggle="toggle">
</div>
</div>
<div ng-hide="phpDetailsBox" class="form-group">
<label class="col-sm-4 control-label">Log Clean</label>
<div class="col-sm-6">
<input type="checkbox" id="log_clean" data-toggle="toggle">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">Max Size</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="max_size" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">Clamav virus</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="CLAMAV_VIRUS"
required>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">Servers</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="server" 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="saveRspamdConfigurations()"
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-6">
<div ng-hide="failedToSave" class="alert alert-danger">
<p>{% trans "Failed to save RSPAMD configurations. Error message: " %}
{$ errorMessage $}</p>
</div>
<div ng-hide="successfullySaved" class="alert alert-success">
<p>{% trans "RSPAMD 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>
<!-----------------------------------------postfix--------------------------->
<div style="padding: 2%" class="col-md-12">
<h3 class="content-box-header">
{% trans "Postfix" %}<img ng-hide="postfixLoading"
src="/static/images/loading.gif">
</h3>
<form action="/" id="createPackages" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-4 control-label">Smtpd Milters</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="smtpd_milters"
required>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">Non Smtpd Milters</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="non_smtpd_milters"
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="savepostfixConfigurations()"
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-6">
<div ng-hide="postfixfailedToSave" class="alert alert-danger">
<p>{% trans "Failed to save Postfix configurations. Error message: " %}
{$ errorMessage $}</p>
</div>
<div ng-hide="postfixsuccessfullySaved" class="alert alert-success">
<p>{% trans "Postfix configurations successfully saved." %}</p>
</div>
<div ng-hide="postfixcouldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>
</div>
</div>
</form>
</div>
<!-----------------------------------------Redis--------------------------->
<div style="padding: 2%" class="col-md-12">
<h3 class="content-box-header">
{% trans "Redis" %}<img ng-hide="RedisLoading" src="/static/images/loading.gif">
</h3>
<form action="/" id="createPackages" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-4 control-label">Write Servers</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="write_servers"
required>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">Read Servers</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="read_servers"
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="saveRedisConfigurations()"
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-6">
<div ng-hide="RedisfailedToSave" class="alert alert-danger">
<p>{% trans "Failed to save Redis configurations. Error message: " %}
{$ errorMessage $}</p>
</div>
<div ng-hide="RedissuccessfullySaved" class="alert alert-success">
<p>{% trans "Redis configurations successfully saved." %}</p>
</div>
<div ng-hide="RediscouldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>
</div>
</div>
</form>
</div>
</div>
{% endif %}
</div>
</div>
</div>
<!----- Modal ----------------------->
<div id="UninstallRspamdmodal" ng-model="UninstallRspamdmodal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;
</button>
<h4 class="modal-title">{% trans "Uninstall Rspamd" %}
</h4>
</div>
<div class="modal-body">
<p> Do You Want to Uninstall Rspamd? </p>
</div>
<div class="modal-footer">
<button type="button"
class="btn btn-primary" data-dismiss="modal" ng-click="unistallRspamd()">yes
</button>
<button type="button"
class="btn btn-default" data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from django.test import TestCase stdout = "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.rspamd/focal,now 1.9.4-2build4 amd64 [residual-config]"
a= stdout.find("installed")
# Create your tests here. if a != -1:
print("1")
else:
print("0")

View File

@@ -42,6 +42,21 @@ urlpatterns = [
url(r'^installMailScanner$', views.installMailScanner, name='installMailScanner'), url(r'^installMailScanner$', views.installMailScanner, name='installMailScanner'),
url(r'^installStatusMailScanner$', views.installStatusMailScanner, name='installStatusMailScanner'), url(r'^installStatusMailScanner$', views.installStatusMailScanner, name='installStatusMailScanner'),
url(r'^Rspamd$', views.Rspamd, name='Rspamd'),
url(r'^installRspamd$', views.installRspamd, name='installRspamd'),
url(r'^installStatusRspamd$', views.installStatusRspamd, name='installStatusRspamd'),
url(r'^fetchRspamdSettings$', views.fetchRspamdSettings, name='fetchRspamdSettings'),
url(r'^saveRspamdConfigurations$', views.saveRspamdConfigurations, name='saveRspamdConfigurations'),
url(r'^savepostfixConfigurations$', views.savepostfixConfigurations, name='savepostfixConfigurations'),
url(r'^saveRedisConfigurations$', views.saveRedisConfigurations, name='saveRedisConfigurations'),
url(r'^saveRedisConfigurations$', views.saveRedisConfigurations, name='saveRedisConfigurations'),
url(r'^unistallRspamd$', views.unistallRspamd, name='unistallRspamd'),
url(r'^uninstallStatusRspamd$', views.uninstallStatusRspamd, name='uninstallStatusRspamd'),
url(r'^(?P<domain>(.*))$', views.emailLimits, name='emailLimits'), url(r'^(?P<domain>(.*))$', views.emailLimits, name='emailLimits'),

View File

@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import time
from django.shortcuts import redirect from django.shortcuts import redirect
from django.http import HttpResponse from django.http import HttpResponse
from mailServer.models import Domains, EUsers from mailServer.models import Domains, EUsers
from plogical.applicationInstaller import ApplicationInstaller
from websiteFunctions.models import Websites from websiteFunctions.models import Websites
from loginSystem.views import loadLoginPage from loginSystem.views import loadLoginPage
import plogical.CyberCPLogFileWriter as logging import plogical.CyberCPLogFileWriter as logging
@@ -17,6 +19,7 @@ from plogical.acl import ACLManager
from plogical.processUtilities import ProcessUtilities from plogical.processUtilities import ProcessUtilities
from plogical.httpProc import httpProc from plogical.httpProc import httpProc
## Email Policy Server ## Email Policy Server
def emailPolicyServer(request): def emailPolicyServer(request):
@@ -24,6 +27,7 @@ def emailPolicyServer(request):
None, 'admin') None, 'admin')
return proc.render() return proc.render()
def fetchPolicyServerStatus(request): def fetchPolicyServerStatus(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -46,8 +50,7 @@ def fetchPolicyServerStatus(request):
installCheck = 1 installCheck = 1
break break
data_ret = {'status': 1, 'error_message': 'None', 'installCheck': installCheck}
data_ret = {'status': 1, 'error_message': 'None', 'installCheck' : installCheck}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) return HttpResponse(json_data)
@@ -63,6 +66,7 @@ def fetchPolicyServerStatus(request):
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) return HttpResponse(json_data)
def savePolicyServerStatus(request): def savePolicyServerStatus(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -111,10 +115,10 @@ def savePolicyServerStatus(request):
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) return HttpResponse(json_data)
## Email Policy Server configs ## Email Policy Server configs
def listDomains(request): def listDomains(request):
websites = DomainLimits.objects.all() websites = DomainLimits.objects.all()
## Check if Policy Server is installed. ## Check if Policy Server is installed.
@@ -152,6 +156,7 @@ def listDomains(request):
{"pagination": pagination, "installCheck": installCheck}, 'admin') {"pagination": pagination, "installCheck": installCheck}, 'admin')
return proc.render() return proc.render()
def getFurtherDomains(request): def getFurtherDomains(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -164,7 +169,6 @@ def getFurtherDomains(request):
try: try:
if request.method == 'POST': if request.method == 'POST':
try: try:
data = json.loads(request.body) data = json.loads(request.body)
@@ -188,13 +192,13 @@ def getFurtherDomains(request):
dic = {'domain': items.domain, 'emails': domain.eusers_set.all().count(), dic = {'domain': items.domain, 'emails': domain.eusers_set.all().count(),
'monthlyLimit': domainLimits.monthlyLimit, 'monthlyUsed': domainLimits.monthlyUsed, 'monthlyLimit': domainLimits.monthlyLimit, 'monthlyUsed': domainLimits.monthlyUsed,
'status':domainLimits.limitStatus} 'status': domainLimits.limitStatus}
if checker == 0: if checker == 0:
json_data = json_data + json.dumps(dic) json_data = json_data + json.dumps(dic)
checker = 1 checker = 1
else: else:
json_data = json_data +',' + json.dumps(dic) json_data = json_data + ',' + json.dumps(dic)
except BaseException as msg: except BaseException as msg:
try: try:
domain = Domains.objects.get(domainOwner=items) domain = Domains.objects.get(domainOwner=items)
@@ -231,6 +235,7 @@ def getFurtherDomains(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def enableDisableEmailLimits(request): def enableDisableEmailLimits(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -241,10 +246,8 @@ def enableDisableEmailLimits(request):
else: else:
return ACLManager.loadErrorJson() return ACLManager.loadErrorJson()
try: try:
if request.method == 'POST': if request.method == 'POST':
data = json.loads(request.body) data = json.loads(request.body)
operationVal = data['operationVal'] operationVal = data['operationVal']
domainName = data['domainName'] domainName = data['domainName']
@@ -258,7 +261,6 @@ def enableDisableEmailLimits(request):
command = 'cyberpanelCleaner purgeLimitDomain ' + domainName + ' ' + str(operationVal) command = 'cyberpanelCleaner purgeLimitDomain ' + domainName + ' ' + str(operationVal)
cacheClient.handleCachePurgeRequest(command) cacheClient.handleCachePurgeRequest(command)
dic = {'status': 1, 'error_message': 'None'} dic = {'status': 1, 'error_message': 'None'}
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
@@ -274,7 +276,8 @@ def enableDisableEmailLimits(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def emailLimits(request,domain):
def emailLimits(request, domain):
if Websites.objects.filter(domain=domain).exists(): if Websites.objects.filter(domain=domain).exists():
website = Websites.objects.get(domain=domain) website = Websites.objects.get(domain=domain)
domainEmail = Domains.objects.get(domainOwner=website) domainEmail = Domains.objects.get(domainOwner=website)
@@ -317,6 +320,7 @@ def emailLimits(request,domain):
'admin') 'admin')
return proc.render() return proc.render()
def changeDomainLimit(request): def changeDomainLimit(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -328,7 +332,6 @@ def changeDomainLimit(request):
return ACLManager.loadErrorJson() return ACLManager.loadErrorJson()
try: try:
if request.method == 'POST': if request.method == 'POST':
data = json.loads(request.body) data = json.loads(request.body)
newLimit = data['newLimit'] newLimit = data['newLimit']
domainName = data['domainName'] domainName = data['domainName']
@@ -357,6 +360,7 @@ def changeDomainLimit(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def getFurtherEmail(request): def getFurtherEmail(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -389,13 +393,13 @@ def getFurtherEmail(request):
dic = {'email': item.email, 'monthlyLimit': emailLts.monthlyLimits, dic = {'email': item.email, 'monthlyLimit': emailLts.monthlyLimits,
'monthlyUsed': emailLts.monthlyUsed, 'hourlyLimit': emailLts.hourlyLimit, 'monthlyUsed': emailLts.monthlyUsed, 'hourlyLimit': emailLts.hourlyLimit,
'hourlyUsed':emailLts.hourlyUsed,'status': emailLts.limitStatus} 'hourlyUsed': emailLts.hourlyUsed, 'status': emailLts.limitStatus}
if checker == 0: if checker == 0:
json_data = json_data + json.dumps(dic) json_data = json_data + json.dumps(dic)
checker = 1 checker = 1
else: else:
json_data = json_data +',' + json.dumps(dic) json_data = json_data + ',' + json.dumps(dic)
except BaseException as msg: except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg)) logging.CyberCPLogFileWriter.writeToFile(str(msg))
@@ -403,7 +407,6 @@ def getFurtherEmail(request):
final_dic = {'status': 1, 'error_message': "None", "data": json_data} final_dic = {'status': 1, 'error_message': "None", "data": json_data}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
except BaseException as msg: except BaseException as msg:
@@ -417,6 +420,7 @@ def getFurtherEmail(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def enableDisableIndividualEmailLimits(request): def enableDisableIndividualEmailLimits(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -428,7 +432,6 @@ def enableDisableIndividualEmailLimits(request):
return ACLManager.loadErrorJson() return ACLManager.loadErrorJson()
try: try:
if request.method == 'POST': if request.method == 'POST':
data = json.loads(request.body) data = json.loads(request.body)
operationVal = data['operationVal'] operationVal = data['operationVal']
emailAddress = data['emailAddress'] emailAddress = data['emailAddress']
@@ -455,6 +458,7 @@ def enableDisableIndividualEmailLimits(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def emailPage(request, emailAddress): def emailPage(request, emailAddress):
Data = {} Data = {}
Data['emailAddress'] = emailAddress Data['emailAddress'] = emailAddress
@@ -480,6 +484,7 @@ def emailPage(request, emailAddress):
proc = httpProc(request, 'emailPremium/emailPage.html', Data, 'admin') proc = httpProc(request, 'emailPremium/emailPage.html', Data, 'admin')
return proc.render() return proc.render()
def getEmailStats(request): def getEmailStats(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -491,14 +496,12 @@ def getEmailStats(request):
return ACLManager.loadErrorJson() return ACLManager.loadErrorJson()
try: try:
if request.method == 'POST': if request.method == 'POST':
data = json.loads(request.body) data = json.loads(request.body)
emailAddress = data['emailAddress'] emailAddress = data['emailAddress']
email = EUsers.objects.get(email=emailAddress) email = EUsers.objects.get(email=emailAddress)
emailLTS = EmailLimits.objects.get(email=email) emailLTS = EmailLimits.objects.get(email=email)
final_dic = {'status': 1, 'error_message': "None", "monthlyLimit": emailLTS.monthlyLimits, final_dic = {'status': 1, 'error_message': "None", "monthlyLimit": emailLTS.monthlyLimits,
'monthlyUsed': emailLTS.monthlyUsed, 'hourlyLimit': emailLTS.hourlyLimit, 'monthlyUsed': emailLTS.monthlyUsed, 'hourlyLimit': emailLTS.hourlyLimit,
'hourlyUsed': emailLTS.hourlyUsed, 'hourlyUsed': emailLTS.hourlyUsed,
@@ -506,7 +509,6 @@ def getEmailStats(request):
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
except BaseException as msg: except BaseException as msg:
@@ -520,6 +522,7 @@ def getEmailStats(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def enableDisableIndividualEmailLogs(request): def enableDisableIndividualEmailLogs(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -531,7 +534,6 @@ def enableDisableIndividualEmailLogs(request):
return ACLManager.loadErrorJson() return ACLManager.loadErrorJson()
try: try:
if request.method == 'POST': if request.method == 'POST':
data = json.loads(request.body) data = json.loads(request.body)
operationVal = data['operationVal'] operationVal = data['operationVal']
emailAddress = data['emailAddress'] emailAddress = data['emailAddress']
@@ -558,6 +560,7 @@ def enableDisableIndividualEmailLogs(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def changeDomainEmailLimitsIndividual(request): def changeDomainEmailLimitsIndividual(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -594,11 +597,11 @@ def changeDomainEmailLimitsIndividual(request):
emailLTS = EmailLimits.objects.get(email=email) emailLTS = EmailLimits.objects.get(email=email)
currentEmailConsumption = emailLTS.monthlyLimits + currentEmailConsumption currentEmailConsumption = emailLTS.monthlyLimits + currentEmailConsumption
allowedLimit = domainLimit.monthlyLimit - currentEmailConsumption allowedLimit = domainLimit.monthlyLimit - currentEmailConsumption
if monthlyLimit > allowedLimit: if monthlyLimit > allowedLimit:
dic = {'status': 0, 'error_message': 'You can not set this monthly limit, first increase limits for this domain.'} dic = {'status': 0,
'error_message': 'You can not set this monthly limit, first increase limits for this domain.'}
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
@@ -612,7 +615,8 @@ def changeDomainEmailLimitsIndividual(request):
emailLTS.save() emailLTS.save()
command = 'cyberpanelCleaner purgeLimitEmail ' + emailAddress + ' ' + str(monthlyLimit) + ' ' + str(hourlyLimit) command = 'cyberpanelCleaner purgeLimitEmail ' + emailAddress + ' ' + str(monthlyLimit) + ' ' + str(
hourlyLimit)
cacheClient.handleCachePurgeRequest(command) cacheClient.handleCachePurgeRequest(command)
dic = {'status': 1, 'error_message': 'None'} dic = {'status': 1, 'error_message': 'None'}
@@ -630,6 +634,7 @@ def changeDomainEmailLimitsIndividual(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def getEmailLogs(request): def getEmailLogs(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -657,7 +662,7 @@ def getEmailLogs(request):
for item in logEntries: for item in logEntries:
dic = {'id': item.id, 'source': emailAddress, 'destination':item.destination, dic = {'id': item.id, 'source': emailAddress, 'destination': item.destination,
'time': item.timeStamp} 'time': item.timeStamp}
if checker == 0: if checker == 0:
@@ -670,7 +675,6 @@ def getEmailLogs(request):
final_dic = {'status': 1, 'error_message': "None", "data": json_data} final_dic = {'status': 1, 'error_message': "None", "data": json_data}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
except BaseException as msg: except BaseException as msg:
@@ -684,6 +688,7 @@ def getEmailLogs(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def flushEmailLogs(request): def flushEmailLogs(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -731,6 +736,7 @@ def spamAssassinHome(request):
{'checkIfSpamAssassinInstalled': checkIfSpamAssassinInstalled}, 'admin') {'checkIfSpamAssassinInstalled': checkIfSpamAssassinInstalled}, 'admin')
return proc.render() return proc.render()
def installSpamAssassin(request): def installSpamAssassin(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -757,6 +763,7 @@ def installSpamAssassin(request):
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
def installStatusSpamAssassin(request): def installStatusSpamAssassin(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -766,7 +773,7 @@ def installStatusSpamAssassin(request):
command = "sudo cat " + mailUtilities.spamassassinInstallLogPath command = "sudo cat " + mailUtilities.spamassassinInstallLogPath
installStatus = ProcessUtilities.outputExecutioner(command) installStatus = ProcessUtilities.outputExecutioner(command)
if installStatus.find("[200]")>-1: if installStatus.find("[200]") > -1:
execPath = "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin && /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin && /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " configureSpamAssassin" execPath = execPath + " configureSpamAssassin"
@@ -797,8 +804,8 @@ def installStatusSpamAssassin(request):
elif installStatus.find("[404]") > -1: elif installStatus.find("[404]") > -1:
final_json = json.dumps({ final_json = json.dumps({
'abort':1, 'abort': 1,
'installed':0, 'installed': 0,
'error_message': "None", 'error_message': "None",
'requestStatus': installStatus, 'requestStatus': installStatus,
}) })
@@ -806,20 +813,22 @@ def installStatusSpamAssassin(request):
else: else:
final_json = json.dumps({ final_json = json.dumps({
'abort':0, 'abort': 0,
'error_message': "None", 'error_message': "None",
'requestStatus': installStatus, 'requestStatus': installStatus,
}) })
return HttpResponse(final_json) return HttpResponse(final_json)
except BaseException as msg: except BaseException as msg:
final_dic = {'abort':1,'installed':0, 'error_message': str(msg)} final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
except KeyError: except KeyError:
final_dic = {'abort':1,'installed':0, 'error_message': "Not Logged In, please refresh the page or login again."} final_dic = {'abort': 1, 'installed': 0,
'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
def fetchSpamAssassinSettings(request): def fetchSpamAssassinSettings(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -846,6 +855,8 @@ def fetchSpamAssassinSettings(request):
data = ProcessUtilities.outputExecutioner(command).splitlines() data = ProcessUtilities.outputExecutioner(command).splitlines()
# logging.CyberCPLogFileWriter.writeToFile(str(data))
for items in data: for items in data:
if items.find('report_safe ') > -1: if items.find('report_safe ') > -1:
if items.find('0') > -1: if items.find('0') > -1:
@@ -882,8 +893,6 @@ def fetchSpamAssassinSettings(request):
final_dic = {'fetchStatus': 1, final_dic = {'fetchStatus': 1,
'installed': 0} 'installed': 0}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
@@ -895,6 +904,7 @@ def fetchSpamAssassinSettings(request):
except KeyError: except KeyError:
return redirect(loadLoginPage) return redirect(loadLoginPage)
def saveSpamAssassinConfigurations(request): def saveSpamAssassinConfigurations(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -923,10 +933,8 @@ def saveSpamAssassinConfigurations(request):
rewrite_header = "rewrite_header " + rewrite_header rewrite_header = "rewrite_header " + rewrite_header
required_score = "required_score " + required_score required_score = "required_score " + required_score
## writing data temporary to file ## writing data temporary to file
tempConfigPath = "/home/cyberpanel/" + str(randint(1000, 9999)) tempConfigPath = "/home/cyberpanel/" + str(randint(1000, 9999))
confPath = open(tempConfigPath, "w") confPath = open(tempConfigPath, "w")
@@ -965,11 +973,13 @@ def saveSpamAssassinConfigurations(request):
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) return HttpResponse(json_data)
def mailQueue(request): def mailQueue(request):
proc = httpProc(request, 'emailPremium/mailQueue.html', proc = httpProc(request, 'emailPremium/mailQueue.html',
None, 'admin') None, 'admin')
return proc.render() return proc.render()
def fetchMailQueue(request): def fetchMailQueue(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -1006,6 +1016,7 @@ def fetchMailQueue(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def fetchMessage(request): def fetchMessage(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -1023,7 +1034,6 @@ def fetchMessage(request):
command = 'postcat -vq %s' % (id) command = 'postcat -vq %s' % (id)
emailMessageContent = ProcessUtilities.outputExecutioner(command) emailMessageContent = ProcessUtilities.outputExecutioner(command)
dic = {'status': 1, 'error_message': 'None', 'emailMessageContent': emailMessageContent} dic = {'status': 1, 'error_message': 'None', 'emailMessageContent': emailMessageContent}
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
@@ -1038,6 +1048,7 @@ def fetchMessage(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def flushQueue(request): def flushQueue(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -1066,6 +1077,7 @@ def flushQueue(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
def delete(request): def delete(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -1101,6 +1113,7 @@ def delete(request):
json_data = json.dumps(dic) json_data = json.dumps(dic)
return HttpResponse(json_data) return HttpResponse(json_data)
## MailScanner ## MailScanner
def MailScanner(request): def MailScanner(request):
@@ -1118,6 +1131,7 @@ def MailScanner(request):
{'checkIfMailScannerInstalled': checkIfMailScannerInstalled, 'ipAddress': ipAddress}, 'admin') {'checkIfMailScannerInstalled': checkIfMailScannerInstalled, 'ipAddress': ipAddress}, 'admin')
return proc.render() return proc.render()
def installMailScanner(request): def installMailScanner(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -1136,7 +1150,8 @@ def installMailScanner(request):
result = ProcessUtilities.outputExecutioner(command) result = ProcessUtilities.outputExecutioner(command)
if result.find('disabled') == -1: if result.find('disabled') == -1:
final_json = json.dumps({'status': 0, 'error_message': "Disable selinux before installing MailScanner."}) final_json = json.dumps(
{'status': 0, 'error_message': "Disable selinux before installing MailScanner."})
return HttpResponse(final_json) return HttpResponse(final_json)
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py" execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
@@ -1154,6 +1169,7 @@ def installMailScanner(request):
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
def installStatusMailScanner(request): def installStatusMailScanner(request):
try: try:
userID = request.session['userID'] userID = request.session['userID']
@@ -1170,7 +1186,7 @@ def installStatusMailScanner(request):
command = "sudo cat " + mailUtilities.mailScannerInstallLogPath command = "sudo cat " + mailUtilities.mailScannerInstallLogPath
installStatus = ProcessUtilities.outputExecutioner(command) installStatus = ProcessUtilities.outputExecutioner(command)
if installStatus.find("[200]")>-1: if installStatus.find("[200]") > -1:
final_json = json.dumps({ final_json = json.dumps({
'error_message': "None", 'error_message': "None",
@@ -1183,8 +1199,8 @@ def installStatusMailScanner(request):
elif installStatus.find("[404]") > -1: elif installStatus.find("[404]") > -1:
final_json = json.dumps({ final_json = json.dumps({
'abort':1, 'abort': 1,
'installed':0, 'installed': 0,
'error_message': "None", 'error_message': "None",
'requestStatus': installStatus, 'requestStatus': installStatus,
}) })
@@ -1192,7 +1208,7 @@ def installStatusMailScanner(request):
else: else:
final_json = json.dumps({ final_json = json.dumps({
'abort':0, 'abort': 0,
'error_message': "None", 'error_message': "None",
'requestStatus': installStatus, 'requestStatus': installStatus,
}) })
@@ -1200,10 +1216,459 @@ def installStatusMailScanner(request):
except BaseException as msg: except BaseException as msg:
final_dic = {'abort':1,'installed':0, 'error_message': str(msg)} final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
except KeyError: except KeyError:
final_dic = {'abort':1,'installed':0, 'error_message': "Not Logged In, please refresh the page or login again."} final_dic = {'abort': 1, 'installed': 0,
'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
###Rspamd
def Rspamd(request):
checkIfRspamdInstalled = 0
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
if mailUtilities.checkIfRspamdInstalled() == 1:
checkIfRspamdInstalled = 1
proc = httpProc(request, 'emailPremium/Rspamd.html',
{'checkIfRspamdInstalled': checkIfRspamdInstalled, 'ipAddress': ipAddress}, 'admin')
return proc.render()
def installRspamd(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson()
try:
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " installRspamd"
ProcessUtilities.popenExecutioner(execPath)
final_json = json.dumps({'status': 1, 'error_message': "None"})
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'status': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'status': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def installStatusRspamd(request):
try:
userID = request.session['userID']
try:
if request.method == 'POST':
command = "sudo cat " + mailUtilities.RspamdInstallLogPath
installStatus = ProcessUtilities.outputExecutioner(command)
if installStatus.find("[200]") > -1:
final_json = json.dumps({
'error_message': "None",
'requestStatus': installStatus,
'abort': 1,
'installed': 1,
})
cmd = 'rm -f %s'%mailUtilities.RspamdInstallLogPath
ProcessUtilities.executioner(cmd)
return HttpResponse(final_json)
elif installStatus.find("[404]") > -1:
final_json = json.dumps({
'abort': 1,
'installed': 0,
'error_message': "None",
'requestStatus': installStatus,
})
cmd = 'rm -f %s' % mailUtilities.RspamdInstallLogPath
ProcessUtilities.executioner(cmd)
return HttpResponse(final_json)
else:
final_json = json.dumps({
'abort': 0,
'error_message': "None",
'requestStatus': installStatus,
})
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'abort': 1, 'installed': 0,
'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def fetchRspamdSettings(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson('fetchStatus', 0)
try:
if request.method == 'POST':
enabled = True
action = ''
max_Size = ''
scan_mime_parts = True
log_clean = True
Server = ''
CLAMAV_VIRUS = ''
confPath = "/etc/rspamd/local.d/antivirus.conf"
postfixpath = "/etc/postfix/main.cf"
if mailUtilities.checkIfRspamdInstalled() == 1:
command = "sudo cat " + confPath
data = ProcessUtilities.outputExecutioner(command).splitlines()
for items in data:
if items.find('enabled ') > -1:
if items.find('enabled = true') < 0:
enabled = False
continue
else:
enabled = True
if items.find('action =') > -1:
tempData = items.split(' ')
# logging.CyberCPLogFileWriter.writeToFile(str(tempData) + "action")
try:
a = tempData[4]
except:
a = tempData[2]
ac = a.split('"')
action = ac[1]
if items.find('max_size') > -1:
tempData = items.split(' ')
max = tempData[4]
max_Size = max.rstrip(";")
if items.find('scan_mime_parts ') > -1:
if items.find('scan_mime_parts = true') < 0:
scan_mime_parts = False
continue
else:
scan_mime_parts = True
if items.find('log_clean ') > -1:
if items.find('scan_mime_parts = true') < 0:
log_clean = False
continue
else:
log_clean = True
if items.find('servers =') > -1:
tempData = items.split(' ')
Ser = tempData[4]
x = Ser.rstrip(";")
y = x.split('"')
Server = y[1]
if items.find('CLAMAV_VIRUS =') > -1:
tempData = items.split(' ')
CLAMAV = tempData[6]
i = CLAMAV.rstrip(";")
j = i.split('"')
CLAMAV_VIRUS = j[1]
###postfix
smtpd_milters = ""
non_smtpd_milters = ""
command = "sudo cat " + postfixpath
postdata = ProcessUtilities.outputExecutioner(command).splitlines()
for i in postdata:
if i.find('smtpd_milters=') > -1 and i.find('non_smtpd_milters') < 0:
tempData = i.split(' ')
x = tempData[0]
y = x.split('=')
smtpd_milters = y[1]
if i.find('non_smtpd_milters=') > -1:
tempData = i.split(' ')
x = tempData[0]
y = x.split('=')
non_smtpd_milters = y[1]
###Redis
Redispath = "/etc/rspamd/local.d/redis.conf"
read_servers = ''
write_servers = ''
command = "sudo cat " + Redispath
postdata = ProcessUtilities.outputExecutioner(command).splitlines()
for i in postdata:
if i.find('write_servers =') > -1:
tempData = i.split(' ')
# logging.CyberCPLogFileWriter.writeToFile(str(tempData) + "redis")
write = tempData[2]
i = write.rstrip(";")
j = i.split('"')
write_servers = j[1]
# logging.CyberCPLogFileWriter.writeToFile(str(write_servers) + "write_servers")
if i.find('read_servers =') > -1:
tempData = i.split(' ')
# logging.CyberCPLogFileWriter.writeToFile(str(tempData) + "redis2")
read = tempData[2]
i = read.rstrip(";")
j = i.split('"')
read_servers = j[1]
# logging.CyberCPLogFileWriter.writeToFile(str(read_servers) + "read_servers")
final_dic = {'fetchStatus': 1,
'installed': 1,
'enabled': enabled,
'action': action,
'max_Size': max_Size,
'scan_mime_parts': scan_mime_parts,
'log_clean ': log_clean,
'Server': Server,
'CLAMAV_VIRUS': CLAMAV_VIRUS,
'smtpd_milters': smtpd_milters,
'non_smtpd_milters': non_smtpd_milters,
'read_servers': read_servers,
'write_servers': write_servers
}
else:
final_dic = {'fetchStatus': 1,
'installed': 0}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
return redirect(loadLoginPage)
def saveRspamdConfigurations(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson('saveStatus', 0)
try:
if request.method == 'POST':
data = json.loads(request.body)
tempfilepath = "/home/cyberpanel/tempfilerspamdconfigs"
json_object = json.dumps(data, indent=4)
writeDataToFile = open(tempfilepath, "w")
writeDataToFile.write(json_object)
writeDataToFile.close()
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " changeRspamdConfig "
output = ProcessUtilities.outputExecutioner(execPath)
data_ret = {'saveStatus': 1, 'error_message': 'None'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError:
return redirect(loadLoginPage)
def savepostfixConfigurations(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson('saveStatus', 0)
try:
if request.method == 'POST':
data = json.loads(request.body)
tempfilepath = "/home/cyberpanel/tempfilepostfixconfigs"
json_object = json.dumps(data, indent=4)
writeDataToFile = open(tempfilepath, "w")
writeDataToFile.write(json_object)
writeDataToFile.close()
# status, msg = mailUtilities.changeRspamdConfig(request.body)
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " changePostfixConfig "
output = ProcessUtilities.outputExecutioner(execPath)
data_ret = {'saveStatus': 1, 'error_message': 'None'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError:
return redirect(loadLoginPage)
def saveRedisConfigurations(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson('saveStatus', 0)
try:
if request.method == 'POST':
data = json.loads(request.body)
tempfilepath = "/home/cyberpanel/saveRedisConfigurations"
json_object = json.dumps(data, indent=4)
writeDataToFile = open(tempfilepath, "w")
writeDataToFile.write(json_object)
writeDataToFile.close()
# status, msg = mailUtilities.changeRspamdConfig(request.body)
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " changeRedisxConfig "
output = ProcessUtilities.outputExecutioner(execPath)
data_ret = {'saveStatus': 1, 'error_message': 'None'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError:
return redirect(loadLoginPage)
def unistallRspamd(request):
try:
logging.CyberCPLogFileWriter.writeToFile("unistallRspamd...1")
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson()
try:
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " uninstallRspamd"
ProcessUtilities.popenExecutioner(execPath)
final_json = json.dumps({'status': 1, 'error_message': "None"})
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'status': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'status': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def uninstallStatusRspamd(request):
try:
userID = request.session['userID']
try:
if request.method == 'POST':
command = "sudo cat " + mailUtilities.RspamdUnInstallLogPath
installStatus = ProcessUtilities.outputExecutioner(command)
if installStatus.find("[200]") > -1:
final_json = json.dumps({
'error_message': "None",
'requestStatus': installStatus,
'abort': 1,
'installed': 1,
})
cmd = 'rm -f %s' % mailUtilities.RspamdUnInstallLogPath
ProcessUtilities.executioner(cmd)
return HttpResponse(final_json)
elif installStatus.find("[404]") > -1:
final_json = json.dumps({
'abort': 1,
'installed': 0,
'error_message': "None",
'requestStatus': installStatus,
})
cmd = 'rm -f %s' % mailUtilities.RspamdUnInstallLogPath
ProcessUtilities.executioner(cmd)
return HttpResponse(final_json)
else:
final_json = json.dumps({
'abort': 0,
'error_message': "None",
'requestStatus': installStatus,
})
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'abort': 1, 'installed': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'abort': 1, 'installed': 0,
'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)

View File

@@ -1,8 +1,11 @@
import json import json
import os,sys import os,sys
import time
from django.http import HttpResponse from django.http import HttpResponse
sys.path.append('/usr/local/CyberCP') sys.path.append('/usr/local/CyberCP')
import django import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
@@ -34,6 +37,8 @@ class mailUtilities:
installLogPath = "/home/cyberpanel/openDKIMInstallLog" installLogPath = "/home/cyberpanel/openDKIMInstallLog"
spamassassinInstallLogPath = "/home/cyberpanel/spamassassinInstallLogPath" spamassassinInstallLogPath = "/home/cyberpanel/spamassassinInstallLogPath"
RspamdInstallLogPath = "/home/cyberpanel/RspamdInstallLogPath"
RspamdUnInstallLogPath = "/home/cyberpanel/RspamdUnInstallLogPath"
cyberPanelHome = "/home/cyberpanel" cyberPanelHome = "/home/cyberpanel"
mailScannerInstallLogPath = "/home/cyberpanel/mailScannerInstallLogPath" mailScannerInstallLogPath = "/home/cyberpanel/mailScannerInstallLogPath"
@@ -495,6 +500,329 @@ milter_default_action = accept
writeToFile.close() writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installSpamAssassin]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installSpamAssassin]")
@staticmethod
def installRspamd(install, rspamd):
from manageServices.serviceManager import ServiceManager
try:
if os.path.exists(mailUtilities.RspamdInstallLogPath):
os.remove(mailUtilities.RspamdInstallLogPath)
####Frist install redis
ServiceManager.InstallRedis()
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
command = 'sudo yum install rspamd clamav clamav-daemon -y'
else:
command = 'sudo apt-get install rspamd clamav clamav-daemon -y'
cmd = shlex.split(command)
with open(mailUtilities.RspamdInstallLogPath, 'w') as f:
res = subprocess.call(cmd, stdout=f)
###### makefile
path = "/etc/rspamd/local.d/antivirus.conf"
content ="""# ================= DO NOT MODIFY THIS FILE =================
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at NethServer official site: https://www.nethserver.org
#
#
#Enable or disable the module
enabled = true
# multiple scanners could be checked, for each we create a configuration block with an arbitrary name
clamav {
# If set force this action if any virus is found (default unset: no action is forced, 'rewrite_subject' to tag as spam)
action = "reject";
# if `true` only messages with non-image attachments will be checked (default true)
scan_mime_parts = false;
# If `max_size` is set, messages > n bytes in size are not scanned
max_size = 20000000;
# type of scanner: "clamav", "fprot", "sophos" or "savapi"
type = "clamav";
# If set true, log message is emitted for clean messages
log_clean = false;
# Timeout and retransmits increased in case of clamav is reloading its database
# It takes a lot of time (25 to 60 seconds), after rspamd answers a temporally failure
#timeout = 5;
#retransmits = 2;
# servers to query (if port is unspecified, scanner-specific default is used)
# can be specified multiple times to pool servers
# can be set to a path to a unix socket
servers = "127.0.0.1:3310";
# if `patterns` is specified virus name will be matched against provided regexes and the related
# symbol will be yielded if a match is found. If no match is found, default symbol is yielded.
patterns {
# symbol_name = "pattern";
CLAMAV_VIRUS = "^Eicar-Test-Signature$";
}
# In version 1.7.0+ patterns could be a list for ordered matching
#patterns = [{SANE_MAL = "Sanesecurity.Malware.*"}, {CLAM_UNOFFICIAL = "UNOFFICIAL$"}];
# `whitelist` points to a map of IP addresses. Mail from these addresses is not scanned.
whitelist = "/etc/rspamd/antivirus.wl";
}
"""
wirtedata = open(path, 'w')
wirtedata.writelines(content)
wirtedata.close()
appendpath = "/etc/postfix/main.cf"
appenddata = """smtpd_milters=inet:127.0.0.1:11332 # For inbound scan or outbound scan via SMTP
non_smtpd_milters=inet:127.0.0.1:11332 # For invocation via LDA
"""
wirtedata1 = open(appendpath, 'a')
wirtedata1.writelines(appenddata)
wirtedata1.close()
wpath = "/etc/rspamd/local.d/redis.conf"
wdata = """write_servers = "127.0.0.1";
read_servers = "127.0.0.1";"""
wirtedata2 = open(wpath, 'w')
wirtedata2.writelines(wdata)
wirtedata2.close()
if res == 1:
writeToFile = open(mailUtilities.RspamdInstallLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile("[Could not Install Rspamd.]")
return 0
else:
writeToFile = open(mailUtilities.RspamdInstallLogPath, 'a')
writeToFile.writelines("Rspamd Installed.[200]\n")
writeToFile.close()
return 1
except BaseException as msg:
writeToFile = open(mailUtilities.RspamdInstallLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installRspamd]")
@staticmethod
def uninstallRspamd(install, rspamd):
from manageServices.serviceManager import ServiceManager
try:
logging.CyberCPLogFileWriter.writeToFile( "start................[uninstallRspamd]")
if os.path.exists(mailUtilities.RspamdUnInstallLogPath):
os.remove(mailUtilities.RspamdUnInstallLogPath)
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
command = 'sudo yum remove rspamd clamav clamav-daemon -y'
else:
command = 'sudo apt purge rspamd clamav clamav-daemon -y'
cmd = shlex.split(command)
with open(mailUtilities.RspamdUnInstallLogPath, 'w') as f:
res = subprocess.call(cmd, stdout=f)
if res == 1:
writeToFile = open(mailUtilities.RspamdUnInstallLogPath, 'a')
writeToFile.writelines("Can not be uninstalled.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile("[Could not Install Rspamd.]")
return 0
else:
cmdd = 'systemctl stop rspamd'
ProcessUtilities.normalExecutioner(cmdd)
cmmd = 'systemctl disable rspamd'
ProcessUtilities.normalExecutioner(cmmd)
writeToFile = open(mailUtilities.RspamdUnInstallLogPath, 'a')
writeToFile.writelines("Rspamd unInstalled.[200]\n")
writeToFile.close()
return 1
except BaseException as msg:
writeToFile = open(mailUtilities.RspamdUnInstallLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[uninstallRspamd]")
@staticmethod
def changeRspamdConfig(install, changeRspamdConfig):
try:
tempfilepath = "/home/cyberpanel/tempfilerspamdconfigs"
file= open(tempfilepath, "r")
jsondata1 = file.read()
jsondata = json.loads(jsondata1)
file.close()
status = jsondata['status']
scan_mime_parts = jsondata['scan_mime_parts']
log_clean = jsondata['log_clean']
max_size = jsondata['max_size']
server = jsondata['Rspamdserver']
CLAMAV_VIRUS = jsondata['CLAMAV_VIRUS']
action_rspamd = jsondata['action_rspamd']
confPath = "/etc/rspamd/local.d/antivirus.conf"
f = open(confPath, "r")
dataa = f.read()
f.close()
data = dataa.splitlines()
writeDataToFile = open(confPath, "w")
for items in data:
if items.find('enabled ') > -1:
if status == True:
command = 'systemctl start rspamd'
ProcessUtilities.executioner(command)
newitem = 'enabled = true'
writeDataToFile.writelines(newitem + '\n')
elif status == False:
command = 'systemctl stop rspamd'
ProcessUtilities.executioner(command)
newitem = 'enabled = false'
writeDataToFile.writelines(newitem + '\n')
elif items.find('action =') > -1:
if action_rspamd == 'Reject':
newitem = ' action = "reject";'
writeDataToFile.writelines(newitem + '\n')
elif action_rspamd == 'Unset':
newitem = ' action = "unset";'
writeDataToFile.writelines(newitem + '\n')
elif items.find('scan_mime_parts') > -1:
if scan_mime_parts == True:
newitem = ' scan_mime_parts = true;'
writeDataToFile.writelines(newitem + '\n')
elif scan_mime_parts == False:
newitem = ' scan_mime_parts = false;'
writeDataToFile.writelines(newitem + '\n')
elif items.find('log_clean =') > -1:
if log_clean == True:
newitem = ' log_clean = true;'
writeDataToFile.writelines(newitem + '\n')
elif log_clean == False:
newitem = ' log_clean = false;'
writeDataToFile.writelines(newitem + '\n')
elif items.find('max_size =') > -1:
newitem = ' max_size = %s;'%max_size
writeDataToFile.writelines(newitem + '\n')
elif items.find('CLAMAV_VIRUS =') > -1:
newitem = ' CLAMAV_VIRUS = "%s";' % CLAMAV_VIRUS
writeDataToFile.writelines(newitem + '\n')
elif items.find('servers =') > -1:
newitem = ' servers = "%s";' % server
writeDataToFile.writelines(newitem + '\n')
else:
writeDataToFile.writelines(items + '\n')
print("1,None")
return 1, 'None'
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[changeRspamdConfig]")
str((msg) + " [changeRspamdConfig]")
print(0, str(msg))
return [0, str(msg) + " [changeRspamdConfig]"]
@staticmethod
def changePostfixConfig(install , changePostfixConfig):
try:
tempfilepath = "/home/cyberpanel/tempfilepostfixconfigs"
file = open(tempfilepath, "r")
jsondata1 = file.read()
jsondata = json.loads(jsondata1)
file.close()
non_smtpd_milters = jsondata['non_smtpd_milters']
smtpd_milters = jsondata['smtpd_milters']
postfixpath = "/etc/postfix/main.cf"
f = open(postfixpath, "r")
dataa = f.read()
f.close()
data = dataa.splitlines()
writeDataToFile = open(postfixpath, "w")
for i in data:
if i.find('smtpd_milters=') > -1 and i.find('non_smtpd_milters') < 0:
newitem = 'smtpd_milters=%s' % smtpd_milters
writeDataToFile.writelines(newitem + '\n')
elif i.find('non_smtpd_milters=') > -1:
newitem = 'non_smtpd_milters=%s' % non_smtpd_milters
writeDataToFile.writelines(newitem + '\n')
else:
writeDataToFile.writelines(i + '\n')
print("1,None")
return 1, 'None'
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[changePostfixConfig]")
str((msg) + " [changePostfixConfig]")
print(0, str(msg))
return [0, str(msg) + " [changePostfixConfig]"]
@staticmethod
def changeRedisxConfig(install, changeRedisxConfig):
try:
tempfilepath = "/home/cyberpanel/saveRedisConfigurations"
file = open(tempfilepath, "r")
jsondata1 = file.read()
jsondata = json.loads(jsondata1)
file.close()
write_servers = jsondata['write_servers']
read_servers = jsondata['read_servers']
Redispath = "/etc/rspamd/local.d/redis.conf"
f = open(Redispath, "r")
dataa = f.read()
f.close()
data = dataa.splitlines()
writeDataToFile = open(Redispath, "w")
for i in data:
if i.find('write_servers =') > -1:
newitem = 'write_servers = "%s";' % write_servers
writeDataToFile.writelines(newitem + '\n')
elif i.find('read_servers =') > -1:
newitem = 'read_servers = "%s";' % read_servers
writeDataToFile.writelines(newitem + '\n')
else:
writeDataToFile.writelines(i + '\n')
print("1,None")
return 1, 'None'
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[changeRedisxConfig]")
str((msg) + " [changeRedisxConfig]")
print(0, str(msg))
return [0, str(msg) + " [changeRedisxConfig]"]
@staticmethod @staticmethod
def installMailScanner(install, SpamAssassin): def installMailScanner(install, SpamAssassin):
try: try:
@@ -745,6 +1073,25 @@ milter_default_action = accept
str(msg) + " [checkIfMailScannerInstalled]") str(msg) + " [checkIfMailScannerInstalled]")
return 0 return 0
@staticmethod
def checkIfRspamdInstalled():
try:
command= "apt list | grep rspamd"
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
resul = stdout.find("installed")
if resul != -1:
return 1
else:
return 0
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [checkIfMailScannerInstalled]")
return 0
####### Imported below functions from mailserver/mailservermanager, need to refactor later ####### Imported below functions from mailserver/mailservermanager, need to refactor later
class MailServerManagerUtils(multi.Thread): class MailServerManagerUtils(multi.Thread):
@@ -1658,8 +2005,18 @@ def main():
mailUtilities.savePolicyServerStatus(args.install) mailUtilities.savePolicyServerStatus(args.install)
elif args.function == 'installSpamAssassin': elif args.function == 'installSpamAssassin':
mailUtilities.installSpamAssassin("install", "SpamAssassin") mailUtilities.installSpamAssassin("install", "SpamAssassin")
elif args.function == 'installRspamd':
mailUtilities.installRspamd("install", "rspamd")
elif args.function == 'uninstallRspamd':
mailUtilities.uninstallRspamd("install", "rspamd")
elif args.function == 'installMailScanner': elif args.function == 'installMailScanner':
mailUtilities.installMailScanner("install", "installMailScanner") mailUtilities.installMailScanner("install", "installMailScanner")
elif args.function == 'changeRspamdConfig':
mailUtilities.changeRspamdConfig("install", "changeRspamdConfig")
elif args.function == 'changePostfixConfig':
mailUtilities.changePostfixConfig("install", "changePostfixConfig")
elif args.function == 'changeRedisxConfig':
mailUtilities.changeRedisxConfig("install", "changeRedisxConfig")
elif args.function == 'AfterEffects': elif args.function == 'AfterEffects':
mailUtilities.AfterEffects(args.domain) mailUtilities.AfterEffects(args.domain)
elif args.function == "ResetEmailConfigurations": elif args.function == "ResetEmailConfigurations":

View File

@@ -1,19 +1,39 @@
a = "/home/folderhabitk.ml/public_html/subfile/" data ="""['# This is the right place to customize your installation of SpamAssassin.', '#', "# See 'perldoc Mail::SpamAssassin::Conf' for details of what can be", '# tweaked.', '#', '# Only a small subset of options are listed below', '#', '###########################################################################', '', '# Add *****SPAM***** to the Subject header of spam e-mails', '#', 'rewrite_header Subject *****SPAM*****', '', '', '# Save spam messages as a message/rfc822 MIME attachment instead of', '# modifying the original message (0: off, 2: use text/plain instead)', '#', 'report_safe 1', '', '', "# Set which networks or hosts are considered 'trusted' by your mail", '# server (i.e. not spammers)', '#', '# trusted_networks 212.17.35.', '', '', '# Set file-locking method (flock is not safe over NFS, but is faster)', '#', '# lock_method flock', '', '', '# Set the threshold at which a message is considered spam (default: 5.0)', '#', 'required_score 5.0', '', '', '# Use Bayesian classifier (default: 1)', '#', '# use_bayes 1', '', '', '# Bayesian classifier auto-learning (default: 1)', '#', '# bayes_auto_learn 1', '', '', '# Set headers which may provide inappropriate cues to the Bayesian', '# classifier', '#', '# bayes_ignore_header X-Bogosity', '# bayes_ignore_header X-Spam-Flag', '# bayes_ignore_header X-Spam-Status', '', '', '# Whether to decode non- UTF-8 and non-ASCII textual parts and recode', '# them to UTF-8 before the text is given over to rules processing.', '#', '# normalize_charset 1', '', '# Textual body scan limit (default: 50000)', '#', '# Amount of data per email text/* mimepart, that will be run through body', '# rules. This enables safer and faster scanning of large messages,', '# perhaps having very large textual attachments. There should be no need', '# to change this well tested default.', '#', '# body_part_scan_size 50000', '', '# Textual rawbody data scan limit (default: 500000)', '#', '# Amount of data per email text/* mimepart, that will be run through', '# rawbody rules.', '#', '# rawbody_part_scan_size 500000', '', '# Some shortcircuiting, if the plugin is enabled', '# ', 'ifplugin Mail::SpamAssassin::Plugin::Shortcircuit', '#', '# default: strongly-whitelisted mails are *really* whitelisted now, if the', '# shortcircuiting plugin is active, causing early exit to save CPU load.', '# Uncomment to turn this on', '#', '# SpamAssassin tries hard not to launch DNS queries before priority -100. ', '# If you want to shortcircuit without launching unneeded queries, make', '# sure such rule priority is below -100. These examples are already:', '#', '# shortcircuit USER_IN_WHITELIST on', '# shortcircuit USER_IN_DEF_WHITELIST on', '# shortcircuit USER_IN_ALL_SPAM_TO on', '# shortcircuit SUBJECT_IN_WHITELIST on', '', '# the opposite; blacklisted mails can also save CPU', '#', '# shortcircuit USER_IN_BLACKLIST on', '# shortcircuit USER_IN_BLACKLIST_TO on', '# shortcircuit SUBJECT_IN_BLACKLIST on', '', '# if you have taken the time to correctly specify your "trusted_networks",', '# this is another good way to save CPU', '#', '# shortcircuit ALL_TRUSTED on', '', '# and a well-trained bayes DB can save running rules, too', '#', '# shortcircuit BAYES_99 spam', '# shortcircuit BAYES_00 ham', '', 'endif # Mail::SpamAssassin::Plugin::Shortcircuit']"""
DomainName ="newweb3.com" report_safe = 0
abc = a.split("/") required_hits = '5.0'
wpexpath = abc[4] rewrite_header = 'Subject [SPAM]'
required_score = '5'
for items in data:
if items.find('report_safe ') > -1:
if items.find('0') > -1:
report_safe = 0
continue
else:
report_safe = 1
if items.find('rewrite_header ') > -1:
tempData = items.split(' ')
rewrite_header = ''
counter = 0
for headerData in tempData:
if counter == 0:
counter = counter + 1
continue
rewrite_header = rewrite_header + headerData.strip('\n') + ' '
continue
if items.find('required_score ') > -1:
required_score = items.split(' ')[1].strip('\n')
continue
if items.find('required_hits ') > -1:
required_hits = items.split(' ')[1].strip('\n')
continue
final_dic = {'fetchStatus': 1,
'installed': 1,
'report_safe': report_safe,
'rewrite_header': rewrite_header,
'required_score': required_score,
'required_hits': required_hits,
}
b=a.rstrip('/') print(final_dic)
c= b.rstrip(wpexpath)
newpath = '/home/%s/public_html/%s' % (DomainName, wpexpath)
if wpexpath != "":
home = "0"
else:
home = "1"
print(wpexpath)
print(c)
# furl = "habi.com/subfolder"
# a=furl[furl.find('/'):]
# print(a)