diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 1347e797a..491b2dac9 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -622,11 +622,16 @@ title="{% trans 'DKIM Manager' %}">{% trans "DKIM Manager" %} {% endif %} +
  • {% trans "Email Debugger" %} +
  • + {% if admin or createEmail %}
  • {% trans "Access Webmail" %}
  • {% endif %} + diff --git a/emailPremium/static/emailPremium/emailPremium.js b/emailPremium/static/emailPremium/emailPremium.js index 0677c9a39..0aa5b4177 100755 --- a/emailPremium/static/emailPremium/emailPremium.js +++ b/emailPremium/static/emailPremium/emailPremium.js @@ -1520,89 +1520,325 @@ app.controller('Rspamd', function ($scope, $http, $timeout, $window) { } - // 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; - // - // - // } - // } }); + +//// Email Debugger + + +app.controller('EmailDebuuger', function ($scope, $http, $timeout, $window) { + + $scope.cyberpanelLoading = true; + $scope.ExecutionStatus = true; + $scope.ReportStatus = true; + + + + $scope.RunServerLevelEmailChecks = function () { + $scope.cyberpanelLoading = false; + + var url = "/emailPremium/RunServerLevelEmailChecks"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + statusFile = response.data.tempStatusPath; + reportFile = response.data.reportFile; + statusFunc(); + + + + + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + + new PNotify({ + title: 'Error', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + }; + + function statusFunc(){ + $scope.cyberpanelLoading = false; + $scope.ExecutionStatus = false; + var url = "/emailPremium/statusFunc"; + + var data = { + statusFile: statusFile + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + if (response.data.status === 1) { + if (response.data.abort === 1) { + $scope.functionProgress = {"width": "100%"}; + $scope.functionStatus = response.data.currentStatus; + $scope.cyberpanelLoading = true; + $scope.ReadReport(); + $timeout.cancel(); + } else { + $scope.functionProgress = {"width": response.data.installationProgress + "%"}; + $scope.functionStatus = response.data.currentStatus; + $timeout(statusFunc, 3000); + } + + } else { + $scope.cyberpanelLoading = true; + $scope.functionStatus = response.data.error_message; + $scope.functionProgress = {"width": response.data.installationProgress + "%"}; + $timeout.cancel(); + } + + } + + function cantLoadInitialData(response) { + $scope.functionProgress = {"width": response.data.installationProgress + "%"}; + $scope.functionStatus = 'Could not connect to server, please refresh this page.'; + $timeout.cancel(); + } + } + + $scope.ReadReport = function () { + + if (reportFile === 'none') { + return; + } + + $scope.cyberpanelLoading = false; + + var url = "/emailPremium/ReadReport"; + + var data = { + reportFile: reportFile + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + var reportResult = JSON.parse(response.data.reportContent); + + if (reportResult.MailSSL === 1) { + $scope.MailSSL = 'Issued and Valid'; + } else { + $scope.MailSSL = 'Not issued or expired.' + } + var report = response.data.report; + + console.log(report); + $scope.Port25 = report.Port25; + $scope.Port587 = report.Port587; + $scope.Port465 = report.Port465; + $scope.Port110 = report.Port110; + $scope.Port143 = report.Port143; + $scope.Port993 = report.Port993; + $scope.Port995 = report.Port995; + //document.getElementById('MailSSLURL').href = 'https://' + report.serverHostName + ":" + report.port + '/cloudAPI/access?token=' + report.token + "&serverUserName=" + report.userName + '&redirect=/manageSSL/sslForMailServer'; + document.getElementById('MailSSLURL').href = '/manageSSL/sslForMailServer'; + + + $scope.ReportStatus = false; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Error', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + + + }; + + $scope.ResetEmailConfigurations = function () { + $scope.cyberpanelLoading = false; + + var url = "/emailPremium/ResetEmailConfigurations"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + statusFile = response.data.tempStatusPath; + reportFile = response.data.reportFile; + reportFile = 'none'; + statusFunc(); + + + + + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + + new PNotify({ + title: 'Error', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + }; + + + + +}); + + +app.controller('emailDebuggerDomainLevel', function ($scope, $http, $timeout, $window) { + $scope.cyberpanelLoading = true; + $scope.ReportStatus = true; + + $scope.debugEmailForSite = function () { + $scope.cyberpanelLoading = false; + + url = "/emailPremium/debugEmailForSite"; + + var data = { + websiteName: $scope.websiteName + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + $scope.status = response.data.status; + $scope.message = response.data.error_message; + $scope.ReportStatus = false; + + } + + function cantLoadInitialData(response) { + $scope.cyberhosting = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + + }; + + $scope.fixMailSSL = function () { + $scope.cyberpanelLoading = false; + url = "/emailPremium/fixMailSSL"; + + var data = { + websiteName: $scope.websiteName + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + + new PNotify({ + title: 'Success', + text: 'Successfully fixed.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + }; + +}); + /* Java script code for Email Policy Server */ app.controller('policyServer', function ($scope, $http, $timeout, $window) { diff --git a/emailPremium/templates/emailPremium/EmailDebugger.html b/emailPremium/templates/emailPremium/EmailDebugger.html new file mode 100644 index 000000000..8370e29c1 --- /dev/null +++ b/emailPremium/templates/emailPremium/EmailDebugger.html @@ -0,0 +1,252 @@ +{% extends "baseTemplate/index.html" %} +{% load i18n %} +{% block title %}{% trans "Email Debugger - CyberPanel" %}{% endblock %} +{% block content %} + + {% load static %} + {% get_current_language as LANGUAGE_CODE %} + + + +
    + +
    +

    {% trans "Email Debugger" %} - {% trans "Queue Docs" %} +

    +

    {% trans "On this page you manage your server Debug Email setting." %}

    +
    + +
    +
    + +

    + {% trans "DEBUG EMAIL SERVER" %} +

    + +
    + +
    +
    + +
    + +
    +
    +
    +

    {$ functionStatus $} +

    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    IssueStatusActions
    Mail Server SSL{$ MailSSL $} + + + +
    Port 25{$ Port25 $} + + + +
    Port 587{$ Port587 $} + + + +
    Port 465{$ Port465 $} + + + +
    Port 110{$ Port110 $} + + + +
    Port 143{$ Port143 $} + + + +
    Port 995{$ Port995 $} + + + +
    Port 993{$ Port993 $} + + + +
    +
    +
    +
    +
    + + +
    + + +
    + +
    +
    + +
    +
    +

    + {% trans "WEBSITE LEVEL EMAIL ISSUES" %} +

    + +
    +
    + + +
    +
    + +
    +
    +
    +
    + + + + + + + + + + + + + +
    StatusActions
    {$ message $} + + +
    +
    +
    +
    +
    +
    + +
    +
    + + + +{% endblock %} \ No newline at end of file diff --git a/emailPremium/urls.py b/emailPremium/urls.py index 9ccc0f8cb..f66aa2443 100755 --- a/emailPremium/urls.py +++ b/emailPremium/urls.py @@ -56,9 +56,23 @@ urlpatterns = [ url(r'^unistallRspamd$', views.unistallRspamd, name='unistallRspamd'), url(r'^uninstallStatusRspamd$', views.uninstallStatusRspamd, name='uninstallStatusRspamd'), + url(r'^EmailDebugger$', views.EmailDebugger, name='EmailDebugger'), + + url(r'^RunServerLevelEmailChecks$', views.RunServerLevelEmailChecks, name='RunServerLevelEmailChecks'), + url(r'^ResetEmailConfigurations$', views.ResetEmailConfigurations, name='ResetEmailConfigurations'), + url(r'^statusFunc$', views.statusFunc, name='statusFunc'), + url(r'^ReadReport$', views.ReadReport, name='ReadReport'), + + + url(r'^debugEmailForSite$', views.debugEmailForSite, name='debugEmailForSite'), + url(r'^fixMailSSL$', views.fixMailSSL, name='fixMailSSL'), + url(r'^(?P(.*))$', views.emailLimits, name='emailLimits'), + + + ] \ No newline at end of file diff --git a/emailPremium/views.py b/emailPremium/views.py index fd951d786..5787ce194 100755 --- a/emailPremium/views.py +++ b/emailPremium/views.py @@ -3,6 +3,8 @@ import time from django.shortcuts import redirect from django.http import HttpResponse + +from loginSystem.models import Administrator from mailServer.models import Domains, EUsers from plogical.applicationInstaller import ApplicationInstaller from websiteFunctions.models import Websites @@ -18,6 +20,7 @@ from random import randint from plogical.acl import ACLManager from plogical.processUtilities import ProcessUtilities from plogical.httpProc import httpProc +from cloudAPI.cloudManager import CloudManager ## Email Policy Server @@ -1672,3 +1675,143 @@ def uninstallStatusRspamd(request): 'error_message': "Not Logged In, please refresh the page or login again."} final_json = json.dumps(final_dic) return HttpResponse(final_json) + + +##Email Debugger + +def EmailDebugger(request): + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + websitesName = ACLManager.findAllSites(currentACL, userID) + + proc = httpProc(request, 'emailPremium/EmailDebugger.html', + {'websiteList': websitesName}, 'admin') + return proc.render() + +def RunServerLevelEmailChecks(request): + try: + userID = request.session['userID'] + ob = CloudManager() + res = ob.RunServerLevelEmailChecks() + return res + except KeyError: + return redirect(loadLoginPage) + + +def ResetEmailConfigurations(request): + try: + userID = request.session['userID'] + ob = CloudManager() + res = ob.ResetEmailConfigurations() + + return res + except KeyError: + return redirect(loadLoginPage) + +def statusFunc(request): + try: + userID = request.session['userID'] + ob = CloudManager(json.loads(request.body)) + #wm = WebsiteManager() + res = ob.statusFunc() + return res + except KeyError: + return redirect(loadLoginPage) + +def ReadReport(request): + try: + userID = request.session['userID'] + try: + ob = CloudManager(json.loads(request.body)) + res = ob.ReadReport() + Result = json.loads(res.content) + status = Result['status'] + #fetch Ip + IP = ACLManager.GetServerIP() + if status == 1: + def CheckPort(port): + import socket + # Create a TCP socket + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + try: + s.settimeout(1) + s.connect((IP, port)) + return 1 + except socket.error as e: + return 0 + finally: + s.close() + + report = {} + + if CheckPort(25): + report['Port25'] = 'Open' + else: + report['Port25'] = 'Closed, mail will not go through.' + + if CheckPort(587): + report['Port587'] = 'Open' + else: + report['Port587'] = 'Closed, mail will not go through.' + + if CheckPort(465): + report['Port465'] = 'Open' + else: + report['Port465'] = 'Closed, mail will not go through.' + + if CheckPort(110): + report['Port110'] = 'Open' + else: + report['Port110'] = 'Closed, POP3 will not work.' + + if CheckPort(143): + report['Port143'] = 'Open' + else: + report['Port143'] = 'Closed, IMAP will not work.' + + if CheckPort(993): + report['Port993'] = 'Open' + else: + report['Port993'] = 'Closed, IMAP will not work.' + + if CheckPort(995): + report['Port995'] = 'Open' + else: + report['Port995'] = 'Closed, POP3 will not work.' + + report['serverHostName'] = IP + finalResult = Result + finalResult['report'] = report + + final_json = json.dumps(finalResult) + return HttpResponse(final_json) + else: + return 0 , Result + + except BaseException as msg: + logging.CyberCPLogFileWriter.writeToFile("Result....3:" + str(msg)) + except KeyError: + return redirect(loadLoginPage) + + +def debugEmailForSite(request): + try: + userID = request.session['userID'] + ob = CloudManager(json.loads(request.body)) + res = ob.debugEmailForSite() + return res + except KeyError: + return redirect(loadLoginPage) + + +def fixMailSSL(request): + try: + userID = request.session['userID'] + admin = Administrator.objects.get(pk=userID) + data={} + cm = CloudManager(json.loads(request.body), admin) + res = cm.fixMailSSL(request) + logging.CyberCPLogFileWriter.writeToFile("Result....3:" + str(res.content)) + return res + except KeyError: + return redirect(loadLoginPage) diff --git a/websiteFunctions/tests.py b/websiteFunctions/tests.py index 059ca4a75..d97a62978 100755 --- a/websiteFunctions/tests.py +++ b/websiteFunctions/tests.py @@ -1,39 +1,6 @@ -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']""" -report_safe = 0 -required_hits = '5.0' -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 +Result = """b'{"status": 1, "reportContent": "{\\"MailSSL\\": 1}"}""" -final_dic = {'fetchStatus': 1, - 'installed': 1, - 'report_safe': report_safe, - 'rewrite_header': rewrite_header, - 'required_score': required_score, - 'required_hits': required_hits, - } - - -print(final_dic) \ No newline at end of file +if Result.find('"status": 1,') > -1: + print("habbi") +else: + print(Result) \ No newline at end of file