Beispiel #1
0
def spamAssassinHome(request):
    try:
        val = request.session['userID']
        admin = Administrator.objects.get(pk=val)

        if admin.type != 1:
            return HttpResponse("Only administrator can view this page.")

        checkIfSpamAssassinInstalled = 0

        if mailUtilities.checkIfSpamAssassinInstalled() == 1:
            checkIfSpamAssassinInstalled = 1

        return render(request, 'emailPremium/SpamAssassin.html',{'checkIfSpamAssassinInstalled': checkIfSpamAssassinInstalled})

    except KeyError:
        return redirect(loadLoginPage)
Beispiel #2
0
def spamAssassinHome(request):
    try:
        userID = request.session['userID']
        currentACL = ACLManager.loadedACL(userID)

        if currentACL['admin'] == 1:
            pass
        else:
            return ACLManager.loadError()

        checkIfSpamAssassinInstalled = 0

        if mailUtilities.checkIfSpamAssassinInstalled() == 1:
            checkIfSpamAssassinInstalled = 1

        return render(request, 'emailPremium/SpamAssassin.html',{'checkIfSpamAssassinInstalled': checkIfSpamAssassinInstalled})

    except KeyError:
        return redirect(loadLoginPage)
Beispiel #3
0
def fetchSpamAssassinSettings(request):
    try:
        val = request.session['userID']
        admin = Administrator.objects.get(pk=val)
        try:
            if request.method == 'POST':

                if admin.type != 1:
                    final_dic = {'fetchStatus': 0, 'error_message': 'Not enough privileges.'}
                    final_json = json.dumps(final_dic)
                    return HttpResponse(final_json)

                report_safe = 0
                required_hits = '5.0'
                rewrite_header = 'Subject [SPAM]'
                required_score = '5'

                confPath = "/etc/mail/spamassassin/local.cf"

                if mailUtilities.checkIfSpamAssassinInstalled() == 1:

                    command = "sudo cat " + confPath

                    data = subprocess.check_output(shlex.split(command)).splitlines()

                    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 = tempData[1] + " " + tempData[2].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,
                                 }

                else:
                    final_dic = {'fetchStatus': 1,
                                 'installed': 0}



                final_json = json.dumps(final_dic)
                return HttpResponse(final_json)


        except BaseException,msg:
            final_dic = {'fetchStatus': 0, 'error_message': str(msg)}
            final_json = json.dumps(final_dic)
            return HttpResponse(final_json)


        return render(request,'managePHP/editPHPConfig.html')
Beispiel #4
0
def fetchSpamAssassinSettings(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':

                report_safe = 0
                required_hits = '5.0'
                rewrite_header = 'Subject [SPAM]'
                required_score = '5'

                confPath = "/etc/mail/spamassassin/local.cf"

                if mailUtilities.checkIfSpamAssassinInstalled() == 1:

                    command = "sudo cat " + confPath

                    data = ProcessUtilities.outputExecutioner(command).splitlines()

                    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,
                                 }

                else:
                    final_dic = {'fetchStatus': 1,
                                 'installed': 0}



                final_json = json.dumps(final_dic)
                return HttpResponse(final_json)


        except BaseException,msg:
            final_dic = {'fetchStatus': 0, 'error_message': str(msg)}
            final_json = json.dumps(final_dic)
            return HttpResponse(final_json)


        return render(request,'managePHP/editPHPConfig.html')